Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(specs): rename composition to composition-full (private) and add composition (public) #4357

Merged
merged 33 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6b11b8c
feat: rename composition to composition-full (private) and add compos…
e-krebs Jan 14, 2025
d9a9d10
fix: add custom paths
shortcuts Jan 14, 2025
93ef4eb
fix: skip custom tests
shortcuts Jan 14, 2025
f090046
fix: algoliasearch cts
shortcuts Jan 14, 2025
46fbfee
fix: cts
shortcuts Jan 14, 2025
6b961b0
fix: algoliasearch
shortcuts Jan 14, 2025
ef94e82
fix: javascript playground
shortcuts Jan 14, 2025
ab3896f
fix: swift duplicates
shortcuts Jan 14, 2025
899dc05
fix: playground
e-krebs Jan 15, 2025
6b777d6
fix: generate composition tests for JS
e-krebs Jan 15, 2025
5788633
fix: more fix for javascript
e-krebs Jan 15, 2025
7f13d4d
fix: more JS fix
e-krebs Jan 15, 2025
48f4825
fix: JS snippets generations
e-krebs Jan 15, 2025
afb8e9f
fix: remove test that doesn't make sense without custom methods
e-krebs Jan 15, 2025
fede5cb
fix: dart generation
e-krebs Jan 15, 2025
c45a50a
fix: dart
shortcuts Jan 16, 2025
57c1b79
Merge branch 'main' into feat/composition-public-package
shortcuts Jan 16, 2025
f95b503
fix: kotlin
shortcuts Jan 17, 2025
c275a13
fix: templates
shortcuts Jan 17, 2025
22a28d3
fix: is variable
shortcuts Jan 17, 2025
606cbb6
fix: imports
shortcuts Jan 17, 2025
bae83d0
fix: javascript tests
shortcuts Jan 20, 2025
c44e17e
fix: Full naming
shortcuts Jan 20, 2025
9178823
fix: kotlin tests
shortcuts Jan 20, 2025
ad0fbcf
fix: javascript
shortcuts Jan 20, 2025
5879c87
fix: JS build
e-krebs Jan 20, 2025
af4bf96
fix: JS playground
e-krebs Jan 20, 2025
ca02d67
fix: JS CTS
e-krebs Jan 20, 2025
45066ed
fix: kotlin CTS
e-krebs Jan 20, 2025
1603ad7
fix generics
millotp Jan 21, 2025
7ec686c
dont gen for swift
millotp Jan 21, 2025
04815d4
Merge remote-tracking branch 'origin/main' into feat/composition-publ…
millotp Jan 21, 2025
660bea5
rollback a bit
millotp Jan 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
targets:
$default:
builders:
json_serializable:
options:
any_map: false
checked: true
create_factory: true
create_to_json: true
disallow_unrecognized_keys: false
explicit_to_json: true
field_rename: none
ignore_unannotated: false
include_if_null: false
17 changes: 17 additions & 0 deletions clients/algoliasearch-client-javascript/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,23 @@ __metadata:
languageName: unknown
linkType: soft

"@algolia/composition@workspace:packages/composition":
version: 0.0.0-use.local
resolution: "@algolia/composition@workspace:packages/composition"
dependencies:
"@algolia/client-common": "npm:5.19.0"
"@algolia/requester-browser-xhr": "npm:5.19.0"
"@algolia/requester-fetch": "npm:5.19.0"
"@algolia/requester-node-http": "npm:5.19.0"
"@arethetypeswrong/cli": "npm:0.17.3"
"@types/node": "npm:22.10.7"
publint: "npm:0.3.2"
rollup: "npm:4.30.1"
tsup: "npm:8.3.5"
typescript: "npm:5.7.3"
languageName: unknown
linkType: soft

"@algolia/ingestion@npm:1.19.0, @algolia/ingestion@workspace:packages/ingestion":
version: 0.0.0-use.local
resolution: "@algolia/ingestion@workspace:packages/ingestion"
Expand Down
18 changes: 17 additions & 1 deletion config/clients.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"clients": [
"abtesting",
"analytics",
"composition",
"ingestion",
"insights",
"monitoring",
Expand Down Expand Up @@ -32,6 +33,10 @@
"name": "algoliasearch",
"output": "clients/algoliasearch-client-dart/packages/algoliasearch"
},
{
"name": "composition",
"output": "clients/algoliasearch-client-dart/packages/client_composition"
},
{
"name": "insights",
"output": "clients/algoliasearch-client-dart/packages/client_insights"
Expand Down Expand Up @@ -64,6 +69,7 @@
"clients": [
"abtesting",
"analytics",
"composition",
"ingestion",
"insights",
"monitoring",
Expand Down Expand Up @@ -91,6 +97,7 @@
"clients": [
"abtesting",
"analytics",
"composition",
"ingestion",
"insights",
"monitoring",
Expand Down Expand Up @@ -134,6 +141,10 @@
"name": "analytics",
"output": "clients/algoliasearch-client-javascript/packages/client-analytics"
},
{
"name": "composition",
"output": "clients/algoliasearch-client-javascript/packages/composition"
},
{
"name": "ingestion",
"output": "clients/algoliasearch-client-javascript/packages/ingestion"
Expand Down Expand Up @@ -163,7 +174,7 @@
"output": "clients/algoliasearch-client-javascript/packages/client-search"
},
{
"name": "composition",
"name": "composition-full",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdyt of admin instead of full?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those extra endpoints are clearly not for admin,
they will be public eventually, just not now.
so 😕

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok make sense so at some point the composition client will be used in favor of the full right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's what I expect, yes

"output": "clients/algoliasearch-client-javascript/packages/client-composition"
}
],
Expand All @@ -185,6 +196,7 @@
"clients": [
"abtesting",
"analytics",
"composition",
"ingestion",
"insights",
"monitoring",
Expand Down Expand Up @@ -212,6 +224,7 @@
"clients": [
"abtesting",
"analytics",
"composition",
"ingestion",
"insights",
"monitoring",
Expand Down Expand Up @@ -239,6 +252,7 @@
"clients": [
"abtesting",
"analytics",
"composition",
"ingestion",
"insights",
"monitoring",
Expand Down Expand Up @@ -273,6 +287,7 @@
"clients": [
"abtesting",
"analytics",
"composition",
"ingestion",
"insights",
"monitoring",
Expand Down Expand Up @@ -300,6 +315,7 @@
"clients": [
"abtesting",
"analytics",
"composition",
"ingestion",
"insights",
"monitoring",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void processOpts() {
additionalProperties.put("sourceFolder", "");
additionalProperties.put("netCoreProjectFile", true);
additionalProperties.put("targetFramework", "netstandard2.1;netstandard2.0");
additionalProperties.put("isSearchClient", client.equals("search"));
additionalProperties.put("is" + Helpers.capitalize(Helpers.camelize((String) additionalProperties.get("client"))) + "Client", true);
additionalProperties.put("apiPackageName", getClientName(client));
additionalProperties.put("equatable", false);
additionalProperties.put("disallowAdditionalPropertiesIfNotPresent", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void processOpts() {
isAlgoliasearchClient = client.equals("algoliasearch");
String version = Helpers.getClientConfigField("dart", "packageVersion");
additionalProperties.put("isAlgoliasearchClient", isAlgoliasearchClient);
additionalProperties.put("is" + Helpers.capitalize(Helpers.camelize((String) additionalProperties.get("client"))) + "Client", true);

// pubspec.yaml
setPubAuthor("Algolia");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void processOpts() {

additionalProperties.put("packageName", client.equals("query-suggestions") ? "suggestions" : client);
additionalProperties.put("enumClassPrefix", true);
additionalProperties.put("isSearchClient", client.equals("search"));
additionalProperties.put("is" + Helpers.capitalize(Helpers.camelize((String) additionalProperties.get("client"))) + "Client", true);

String outputFolder = "algolia" + File.separator + client;
setOutputDir(getOutputDir() + File.separator + outputFolder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void processOpts() {
final String invokerFolder = (sourceFolder + '/' + invokerPackage).replace(".", "/");
supportingFiles.add(new SupportingFile("build_config.mustache", invokerFolder, "BuildConfig.java"));
supportingFiles.add(new SupportingFile("gradle.properties.mustache", "", "gradle.properties"));
additionalProperties.put("isSearchClient", client.equals("search"));
additionalProperties.put("is" + Helpers.capitalize(Helpers.camelize((String) additionalProperties.get("client"))) + "Client", true);

Helpers.addCommonSupportingFiles(supportingFiles, "");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class AlgoliaJavascriptGenerator extends TypeScriptNodeClientCodegen {

private String CLIENT;
private boolean isAlgoliasearchClient;
private boolean isAlgoliaCompositionClient;

@Override
public String getName() {
Expand All @@ -31,7 +30,6 @@ public void processOpts() {

CLIENT = Helpers.camelize((String) additionalProperties.get("client"));
isAlgoliasearchClient = CLIENT.equals("algoliasearch");
isAlgoliaCompositionClient = CLIENT.equals("composition");

// generator specific options
setSupportsES6(true);
Expand Down Expand Up @@ -154,9 +152,10 @@ private void setDefaultGeneratorOptions() {
String packageName = getPackageName((String) additionalProperties.get("client"));

additionalProperties.put("apiName", CLIENT);
additionalProperties.put("clientName", clientName);
// Just so the full client doesn't have the weird Full naming
additionalProperties.put("clientName", CLIENT.contains("composition") ? "composition" + Helpers.API_SUFFIX : clientName);
additionalProperties.put("algoliaAgent", Helpers.capitalize(CLIENT));
additionalProperties.put("is" + Helpers.capitalize(CLIENT) + "Client", true);
additionalProperties.put("is" + Helpers.capitalize(Helpers.camelize((String) additionalProperties.get("client"))) + "Client", true);
additionalProperties.put("isSearchClient", CLIENT.equals("search") || isAlgoliasearchClient);
additionalProperties.put("isAlgoliasearchClient", isAlgoliasearchClient);
additionalProperties.put("packageVersion", Helpers.getPackageJsonVersion(packageName));
Expand Down Expand Up @@ -186,7 +185,7 @@ private void setDefaultGeneratorOptions() {
dependency.put("withInitMethod", !name.contains("search"));
dependency.put(
"dependencyHasRegionalHosts",
!name.contains("search") && !name.contains("recommend") && !name.contains("monitoring")
!name.contains("search") && !name.contains("recommend") && !name.contains("monitoring") && !name.startsWith("composition")
);

dependencies.add(dependency);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void processOpts() {
supportingFiles.removeIf(file -> file.getTemplateFile().contains("auth"));

// Search config
additionalProperties.put("isSearchClient", client.equals("search"));
additionalProperties.put("is" + Helpers.capitalize(Helpers.camelize((String) additionalProperties.get("client"))) + "Client", true);

// We don't extend hashmap
propertyAdditionalKeywords.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void processOpts() {

Helpers.addCommonSupportingFiles(supportingFiles, "");

additionalProperties.put("isSearchClient", client.equals("search"));
additionalProperties.put("is" + Helpers.capitalize(Helpers.camelize((String) additionalProperties.get("client"))) + "Client", true);
additionalProperties.put("configClassname", getClientName(client) + "Config");

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public String getName() {
public void processOpts() {
CLIENT = (String) additionalProperties.get("client");

additionalProperties.put("isSearchClient", CLIENT.equals("search"));
additionalProperties.put("is" + Helpers.capitalize(Helpers.camelize((String) additionalProperties.get("client"))) + "Client", true);
additionalProperties.put("packageVersion", Helpers.getClientConfigField("python", "packageVersion"));
additionalProperties.put(CodegenConstants.EXCLUDE_TESTS, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public String getName() {
public void processOpts() {
CLIENT = (String) additionalProperties.get("client");

additionalProperties.put("isSearchClient", CLIENT.equals("search"));
additionalProperties.put("is" + Helpers.capitalize(Helpers.camelize((String) additionalProperties.get("client"))) + "Client", true);
additionalProperties.put("packageVersion", Helpers.getClientConfigField("ruby", "packageVersion"));
setGemName("algolia");
additionalProperties.put("modelModule", Helpers.capitalize(Helpers.camelize(CLIENT)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void processOpts() {

Helpers.addCommonSupportingFiles(supportingFiles, "");

additionalProperties.put("isSearchClient", client.equals("search"));
additionalProperties.put("is" + Helpers.capitalize(Helpers.camelize((String) additionalProperties.get("client"))) + "Client", true);
typeMapping.put("AnyType", "Any");

nameMapping.putAll(NAME_MAPPING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public void processOpts() {
System.exit(1);
}

additionalProperties.put("isSearchClient", CLIENT.equals("search"));
additionalProperties.put("is" + Helpers.capitalize(Helpers.camelize((String) additionalProperties.get("client"))) + "Client", true);
additionalProperties.put(CodegenConstants.EXCLUDE_TESTS, true);

additionalProperties.put(RESPONSE_AS, new String[] { RESPONSE_LIBRARY_ASYNC_AWAIT });
Expand Down Expand Up @@ -301,14 +301,14 @@ public void processOpenAPI(OpenAPI openAPI) {
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> models) {
OperationsMap operations = super.postProcessOperationsWithModels(objs, models);
Helpers.removeHelpers(operations);
GenericPropagator.propagateGenericsToOperations(operations, models);
GenericPropagator.propagateGenericsToOperations("swift", CLIENT, operations, models);
return operations;
}

@Override
public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs) {
Map<String, ModelsMap> models = super.postProcessAllModels(objs);
GenericPropagator.propagateGenericsToModels(models);
GenericPropagator.propagateGenericsToModels("swift", CLIENT, models);
OneOf.updateModelsOneOf(models, modelPackage);
OneOf.addOneOfMetadata(models);
return models;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ public Map<String, Object> postProcessSupportingFileData(Map<String, Object> obj

// We can put whatever we want in the bundle, and it will be accessible in the template
bundle.put("mode", mode);
bundle.put("is" + Helpers.capitalize(client) + "Client", true);
bundle.put("isStandaloneClient", client.contains("search") || client.equals("composition"));
bundle.put("is" + Helpers.capitalize(Helpers.camelize(client)) + "Client", true);
bundle.put("isStandaloneClient", client.contains("search") || client.contains("composition"));
bundle.put("isSearchClient", client.contains("search")); // just so algoliasearch is treated as a search client too
bundle.put("client", Helpers.createClientName(importClientName, language) + "Client");
bundle.put("clientPrefix", Helpers.createClientName(importClientName, language));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,23 @@ public void addDataToBundle(Map<String, Object> bundle) throws GeneratorExceptio
bundle.put("utilsPackageVersion", Helpers.getPackageJsonVersion("client-common"));
bundle.put("algoliasearchVersion", Helpers.getPackageJsonVersion("algoliasearch"));
bundle.put("initMethod", "init" + Helpers.capitalize(Helpers.camelize(client)));
bundle.put(
"clientName",
client.equals("algoliasearch") ? "liteClient" : client.equals("composition") ? "compositionClient" : "algoliasearch"
);
bundle.put(
"importPackage",
client.equals("algoliasearch") ? "algoliasearch/lite" : client.equals("composition") ? "@algolia/client-composition" : "algoliasearch"
);

switch (client) {
case "composition":
bundle.put("clientName", "compositionClient");
bundle.put("importPackage", "@algolia/composition");
break;
case "composition-full":
bundle.put("clientName", "compositionClient");
bundle.put("importPackage", "@algolia/client-composition");
break;
case "algoliasearch":
bundle.put("clientName", "liteClient");
bundle.put("importPackage", "algoliasearch/lite");
break;
default:
bundle.put("clientName", "algoliasearch");
bundle.put("importPackage", "algoliasearch");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ public void run(Map<String, CodegenModel> models, Map<String, CodegenOperation>
} else if (step.type.equals("method")) {
ope = operations.get(step.method);
if (ope == null) {
// some clients don't have custom methods
if (step.method.startsWith("custom") && client.equals("composition")) {
continue skipTest;
}

throw new CTSException("Cannot find operation for method: " + step.method, test.testName);
}
stepOut.put("stepTemplate", "tests/client/method.mustache");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,15 @@ protected <T> Map<String, T> loadCTS(String path, String clientName, Class<T> js

Map<String, T> cts = new TreeMap<>();

for (File f : allTests) {
skipFile: for (File f : allTests) {
String json = new String(Files.readAllBytes(Paths.get(f.getAbsolutePath())));
json = injectVariables(json);
cts.put(f.getName().replace(".json", ""), Json.mapper().readValue(json, jsonType));
String key = f.getName().replace(".json", "");
// some clients don't have custom methods
if (clientName.equals("composition") && (key.equals("commonApi") || key.equals("setClientApiKey"))) {
continue skipFile;
}
cts.put(key, Json.mapper().readValue(json, jsonType));
}
return cts;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ public void run(Map<String, CodegenModel> models, Map<String, CodegenOperation>
List<Object> blocksE2E = new ArrayList<>();
ParametersWithDataType paramsType = new ParametersWithDataType(models, language, client, false);

bundle.put("e2eAppID", client.equals("composition") ? "METIS_APPLICATION_ID" : "ALGOLIA_APPLICATION_ID");
bundle.put("e2eAppID", client.startsWith("composition") ? "METIS_APPLICATION_ID" : "ALGOLIA_APPLICATION_ID");
bundle.put(
"e2eApiKey",
client.equals("composition") ? "METIS_API_KEY" : (client.equals("monitoring") ? "MONITORING_API_KEY" : "ALGOLIA_ADMIN_KEY")
client.startsWith("composition") ? "METIS_API_KEY" : (client.equals("monitoring") ? "MONITORING_API_KEY" : "ALGOLIA_ADMIN_KEY")
);
bundle.put("useEchoRequester", true);

Expand Down
Loading