From 79cdf487bab7f37337e447ddc8c83d803d8301ae Mon Sep 17 00:00:00 2001 From: Levi Whalen Date: Fri, 22 Nov 2024 09:11:28 -0700 Subject: [PATCH 01/11] add dart onboarding guide --- .../guides/search/saveObjectsMovies.mustache | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 templates/dart/guides/search/saveObjectsMovies.mustache diff --git a/templates/dart/guides/search/saveObjectsMovies.mustache b/templates/dart/guides/search/saveObjectsMovies.mustache new file mode 100644 index 0000000000..9b33de6cb9 --- /dev/null +++ b/templates/dart/guides/search/saveObjectsMovies.mustache @@ -0,0 +1,40 @@ +import 'package:http/http.dart' as http; +import 'dart:convert'; +{{> snippets/import}} + +void main() async { + // initiate client + {{> snippets/init}} + + // read json file from url + final datasetRequest = await http.get( + Uri.parse('https://dashboard.algolia.com/sample_datasets/movie.json')); + + if (datasetRequest.statusCode == 200) { + final moviesData = jsonDecode(datasetRequest.body); + + final batchRequests = []; + + for (final movie in moviesData) { + batchRequests.add( + BatchRequest(action: Action.fromJson('addObject'), body: movie), + ); + } + + // testing algolia method snippet + {{#dynamicSnippet}}saveObjectsMovies{{/dynamicSnippet}} + + try { + // push data to algolia + await client.batch( + indexName: 'movies_index', + batchWriteParams: BatchWriteParams(requests: batchRequests), + ); + print("Successfully indexed records!"); + } catch (e) { + print("Error: ${e.toString()}"); + } + } else { + throw Exception('Failed to load data'); + } +} From 16587f0648400540b930e0e3103af548a899a1ba Mon Sep 17 00:00:00 2001 From: Levi Whalen Date: Mon, 25 Nov 2024 08:49:16 -0700 Subject: [PATCH 02/11] try removing dynamic snippet --- templates/dart/guides/search/saveObjectsMovies.mustache | 3 --- 1 file changed, 3 deletions(-) diff --git a/templates/dart/guides/search/saveObjectsMovies.mustache b/templates/dart/guides/search/saveObjectsMovies.mustache index 9b33de6cb9..4f647c4303 100644 --- a/templates/dart/guides/search/saveObjectsMovies.mustache +++ b/templates/dart/guides/search/saveObjectsMovies.mustache @@ -21,9 +21,6 @@ void main() async { ); } - // testing algolia method snippet - {{#dynamicSnippet}}saveObjectsMovies{{/dynamicSnippet}} - try { // push data to algolia await client.batch( From 1db53e13e0f69bf163219adc4af49a268153a04d Mon Sep 17 00:00:00 2001 From: Levi Whalen Date: Mon, 25 Nov 2024 13:05:25 -0700 Subject: [PATCH 03/11] try adding dependencies --- .../dart/guides/search/.gitignore.mustache | 25 +++++++++++ .../guides/search/analysis_options.mustache | 1 + templates/dart/guides/search/import.mustache | 1 + templates/dart/guides/search/init.mustache | 1 + templates/dart/guides/search/method.mustache | 45 +++++++++++++++++++ templates/dart/guides/search/pubspec.mustache | 15 +++++++ .../guides/search/pubspec_overrides.mustache | 11 +++++ 7 files changed, 99 insertions(+) create mode 100644 templates/dart/guides/search/.gitignore.mustache create mode 100644 templates/dart/guides/search/analysis_options.mustache create mode 100644 templates/dart/guides/search/import.mustache create mode 100644 templates/dart/guides/search/init.mustache create mode 100644 templates/dart/guides/search/method.mustache create mode 100644 templates/dart/guides/search/pubspec.mustache create mode 100644 templates/dart/guides/search/pubspec_overrides.mustache diff --git a/templates/dart/guides/search/.gitignore.mustache b/templates/dart/guides/search/.gitignore.mustache new file mode 100644 index 0000000000..937bf28bbe --- /dev/null +++ b/templates/dart/guides/search/.gitignore.mustache @@ -0,0 +1,25 @@ +# Files and directories created by pub +.dart_tool/ +.buildlog +.packages +.project +.pub/ +build/ + +# Files created by dart2js +*.dart.js +*.part.js +*.js.deps +*.js.map +*.info.json + +# Directory created by dartdoc +doc/api/ + +# Don't commit pubspec lock file +pubspec.lock + +# IntelliJ +*.iml +*.ipr +*.iws diff --git a/templates/dart/guides/search/analysis_options.mustache b/templates/dart/guides/search/analysis_options.mustache new file mode 100644 index 0000000000..572dd239d0 --- /dev/null +++ b/templates/dart/guides/search/analysis_options.mustache @@ -0,0 +1 @@ +include: package:lints/recommended.yaml diff --git a/templates/dart/guides/search/import.mustache b/templates/dart/guides/search/import.mustache new file mode 100644 index 0000000000..6ddcdd79d2 --- /dev/null +++ b/templates/dart/guides/search/import.mustache @@ -0,0 +1 @@ +import '{{{import}}}'; \ No newline at end of file diff --git a/templates/dart/guides/search/init.mustache b/templates/dart/guides/search/init.mustache new file mode 100644 index 0000000000..249b821973 --- /dev/null +++ b/templates/dart/guides/search/init.mustache @@ -0,0 +1 @@ +final client = {{client}}(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY'{{#hasRegionalHost}}, region: 'ALGOLIA_APPLICATION_REGION'{{/hasRegionalHost}}); \ No newline at end of file diff --git a/templates/dart/guides/search/method.mustache b/templates/dart/guides/search/method.mustache new file mode 100644 index 0000000000..bb3b6320fb --- /dev/null +++ b/templates/dart/guides/search/method.mustache @@ -0,0 +1,45 @@ +// {{generationBanner}} +// >IMPORT +{{> snippets/import}} +// IMPORT< + +{{#blocksRequests}} +{{#snippets}} +// Snippet for the {{{method}}} method. +// +// {{{description}}} +void snippetFor{{method}}{{testIndex}}() async { + // >SEPARATOR {{method}} {{{testName}}} + // Initialize the client + {{> snippets/init}} + + // Call the API + {{#hasResponse}}final response = {{/hasResponse}}{{#isAsyncMethod}}await {{/isAsyncMethod}}client.{{method}}( + {{#parametersWithDataType}} + {{> tests/request_param}} + {{/parametersWithDataType}} + {{#hasRequestOptions}} + requestOptions : RequestOptions( + {{#requestOptions.headers}} + headers: { + {{#parametersWithDataType}} + '{{{key}}}' : '{{value}}', + {{/parametersWithDataType}} + }, + {{/requestOptions.headers}} + {{#requestOptions.queryParameters}} + urlParameters: { + {{#parametersWithDataType}} + '{{{key}}}' : {{> tests/param_value}}, + {{/parametersWithDataType}} + }, + {{/requestOptions.queryParameters}} + ), + {{/hasRequestOptions}} + ); + // >LOG + // SEPARATOR< +} + +{{/snippets}} +{{/blocksRequests}} \ No newline at end of file diff --git a/templates/dart/guides/search/pubspec.mustache b/templates/dart/guides/search/pubspec.mustache new file mode 100644 index 0000000000..b23129b2be --- /dev/null +++ b/templates/dart/guides/search/pubspec.mustache @@ -0,0 +1,15 @@ +name: algolia_snippets +version: 1.0.0 + +environment: + sdk: ^3.0.0 + +dependencies: + algoliasearch: ^1.0.0 + algolia_client_search: ^1.0.0 + algolia_client_insights: ^1.0.0 + algolia_client_recommend: ^1.0.0 + dotenv: ^4.1.0 + +dev_dependencies: + lints: ^5.0.0 diff --git a/templates/dart/guides/search/pubspec_overrides.mustache b/templates/dart/guides/search/pubspec_overrides.mustache new file mode 100644 index 0000000000..8186223507 --- /dev/null +++ b/templates/dart/guides/search/pubspec_overrides.mustache @@ -0,0 +1,11 @@ +dependency_overrides: + algoliasearch: + path: ../../../clients/algoliasearch-client-dart/packages/algoliasearch + algolia_client_core: + path: ../../../clients/algoliasearch-client-dart/packages/client_core + algolia_client_search: + path: ../../../clients/algoliasearch-client-dart/packages/client_search + algolia_client_insights: + path: ../../../clients/algoliasearch-client-dart/packages/client_insights + algolia_client_recommend: + path: ../../../clients/algoliasearch-client-dart/packages/client_recommend \ No newline at end of file From d15b23d493a3764b7d4a9fc0b2aca89aeae519ad Mon Sep 17 00:00:00 2001 From: Levi Whalen Date: Mon, 25 Nov 2024 13:19:35 -0700 Subject: [PATCH 04/11] move fles --- templates/dart/guides/{search => }/.gitignore.mustache | 0 templates/dart/guides/{search => }/analysis_options.mustache | 0 templates/dart/guides/{search => }/import.mustache | 0 templates/dart/guides/{search => }/init.mustache | 0 templates/dart/guides/{search => }/method.mustache | 0 templates/dart/guides/{search => }/pubspec.mustache | 0 templates/dart/guides/{search => }/pubspec_overrides.mustache | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename templates/dart/guides/{search => }/.gitignore.mustache (100%) rename templates/dart/guides/{search => }/analysis_options.mustache (100%) rename templates/dart/guides/{search => }/import.mustache (100%) rename templates/dart/guides/{search => }/init.mustache (100%) rename templates/dart/guides/{search => }/method.mustache (100%) rename templates/dart/guides/{search => }/pubspec.mustache (100%) rename templates/dart/guides/{search => }/pubspec_overrides.mustache (100%) diff --git a/templates/dart/guides/search/.gitignore.mustache b/templates/dart/guides/.gitignore.mustache similarity index 100% rename from templates/dart/guides/search/.gitignore.mustache rename to templates/dart/guides/.gitignore.mustache diff --git a/templates/dart/guides/search/analysis_options.mustache b/templates/dart/guides/analysis_options.mustache similarity index 100% rename from templates/dart/guides/search/analysis_options.mustache rename to templates/dart/guides/analysis_options.mustache diff --git a/templates/dart/guides/search/import.mustache b/templates/dart/guides/import.mustache similarity index 100% rename from templates/dart/guides/search/import.mustache rename to templates/dart/guides/import.mustache diff --git a/templates/dart/guides/search/init.mustache b/templates/dart/guides/init.mustache similarity index 100% rename from templates/dart/guides/search/init.mustache rename to templates/dart/guides/init.mustache diff --git a/templates/dart/guides/search/method.mustache b/templates/dart/guides/method.mustache similarity index 100% rename from templates/dart/guides/search/method.mustache rename to templates/dart/guides/method.mustache diff --git a/templates/dart/guides/search/pubspec.mustache b/templates/dart/guides/pubspec.mustache similarity index 100% rename from templates/dart/guides/search/pubspec.mustache rename to templates/dart/guides/pubspec.mustache diff --git a/templates/dart/guides/search/pubspec_overrides.mustache b/templates/dart/guides/pubspec_overrides.mustache similarity index 100% rename from templates/dart/guides/search/pubspec_overrides.mustache rename to templates/dart/guides/pubspec_overrides.mustache From 8a3e831dbb24bc2ec8f4285b55366c6393e07fab Mon Sep 17 00:00:00 2001 From: Levi Whalen Date: Mon, 25 Nov 2024 14:34:36 -0700 Subject: [PATCH 05/11] trying --- scripts/formatter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/formatter.ts b/scripts/formatter.ts index b011baedb5..b263dec3a1 100644 --- a/scripts/formatter.ts +++ b/scripts/formatter.ts @@ -21,7 +21,7 @@ export async function formatter(language: string, cwd: string): Promise { language, }); } else { - await run('dart pub get && melos bs && melos build --no-select && melos lint', { + await run('dart pub get && dart pub outdated && melos bs && melos build --no-select && melos lint', { cwd, language, }); From c571befb067841490af7933458dcf60f5253d3e9 Mon Sep 17 00:00:00 2001 From: Levi Whalen Date: Mon, 25 Nov 2024 14:34:59 -0700 Subject: [PATCH 06/11] hi From a2c8a3c3acb3a36884ebad9c3ef34da4f3e2c076 Mon Sep 17 00:00:00 2001 From: shortcuts Date: Mon, 25 Nov 2024 22:37:47 +0100 Subject: [PATCH 07/11] fix: dart guides generation --- scripts/formatter.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/formatter.ts b/scripts/formatter.ts index b263dec3a1..89cefa43e9 100644 --- a/scripts/formatter.ts +++ b/scripts/formatter.ts @@ -15,13 +15,13 @@ export async function formatter(language: string, cwd: string): Promise { } break; case 'dart': - if (cwd.includes('tests') || cwd.includes('snippets')) { - await run('dart pub get && dart fix --apply && dart format .', { + if (cwd.includes('clients')) { + await run('dart pub get && melos bs && melos build --no-select && melos lint', { cwd, language, }); } else { - await run('dart pub get && dart pub outdated && melos bs && melos build --no-select && melos lint', { + await run('dart pub get && dart fix --apply && dart format .', { cwd, language, }); From 6e5e8c7263ebb4e12c48f68d6656b452ee905233 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Tue, 26 Nov 2024 09:28:21 +0100 Subject: [PATCH 08/11] fix build --- templates/dart/guides/pubspec.mustache | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/dart/guides/pubspec.mustache b/templates/dart/guides/pubspec.mustache index b23129b2be..611be03f22 100644 --- a/templates/dart/guides/pubspec.mustache +++ b/templates/dart/guides/pubspec.mustache @@ -10,6 +10,7 @@ dependencies: algolia_client_insights: ^1.0.0 algolia_client_recommend: ^1.0.0 dotenv: ^4.1.0 + http: ^0.13.3 dev_dependencies: lints: ^5.0.0 From 9aac0b629a5a495d357e7911e90f6324a7e32258 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Tue, 26 Nov 2024 09:32:21 +0100 Subject: [PATCH 09/11] newer version --- templates/dart/guides/pubspec.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/dart/guides/pubspec.mustache b/templates/dart/guides/pubspec.mustache index 611be03f22..966755ca0d 100644 --- a/templates/dart/guides/pubspec.mustache +++ b/templates/dart/guides/pubspec.mustache @@ -10,7 +10,7 @@ dependencies: algolia_client_insights: ^1.0.0 algolia_client_recommend: ^1.0.0 dotenv: ^4.1.0 - http: ^0.13.3 + http: ^1.2.2 dev_dependencies: lints: ^5.0.0 From 2c7b7f44fcf6d51dd8ee9c961a7f17e263183ad5 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Tue, 26 Nov 2024 09:38:57 +0100 Subject: [PATCH 10/11] not here --- templates/dart/guides/.gitignore.mustache | 25 ----------- .../dart/guides/analysis_options.mustache | 1 - templates/dart/guides/import.mustache | 1 - templates/dart/guides/init.mustache | 1 - templates/dart/guides/method.mustache | 45 ------------------- templates/dart/guides/pubspec.mustache | 16 ------- .../dart/guides/pubspec_overrides.mustache | 11 ----- templates/dart/snippets/pubspec.mustache | 3 +- 8 files changed, 2 insertions(+), 101 deletions(-) delete mode 100644 templates/dart/guides/.gitignore.mustache delete mode 100644 templates/dart/guides/analysis_options.mustache delete mode 100644 templates/dart/guides/import.mustache delete mode 100644 templates/dart/guides/init.mustache delete mode 100644 templates/dart/guides/method.mustache delete mode 100644 templates/dart/guides/pubspec.mustache delete mode 100644 templates/dart/guides/pubspec_overrides.mustache diff --git a/templates/dart/guides/.gitignore.mustache b/templates/dart/guides/.gitignore.mustache deleted file mode 100644 index 937bf28bbe..0000000000 --- a/templates/dart/guides/.gitignore.mustache +++ /dev/null @@ -1,25 +0,0 @@ -# Files and directories created by pub -.dart_tool/ -.buildlog -.packages -.project -.pub/ -build/ - -# Files created by dart2js -*.dart.js -*.part.js -*.js.deps -*.js.map -*.info.json - -# Directory created by dartdoc -doc/api/ - -# Don't commit pubspec lock file -pubspec.lock - -# IntelliJ -*.iml -*.ipr -*.iws diff --git a/templates/dart/guides/analysis_options.mustache b/templates/dart/guides/analysis_options.mustache deleted file mode 100644 index 572dd239d0..0000000000 --- a/templates/dart/guides/analysis_options.mustache +++ /dev/null @@ -1 +0,0 @@ -include: package:lints/recommended.yaml diff --git a/templates/dart/guides/import.mustache b/templates/dart/guides/import.mustache deleted file mode 100644 index 6ddcdd79d2..0000000000 --- a/templates/dart/guides/import.mustache +++ /dev/null @@ -1 +0,0 @@ -import '{{{import}}}'; \ No newline at end of file diff --git a/templates/dart/guides/init.mustache b/templates/dart/guides/init.mustache deleted file mode 100644 index 249b821973..0000000000 --- a/templates/dart/guides/init.mustache +++ /dev/null @@ -1 +0,0 @@ -final client = {{client}}(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY'{{#hasRegionalHost}}, region: 'ALGOLIA_APPLICATION_REGION'{{/hasRegionalHost}}); \ No newline at end of file diff --git a/templates/dart/guides/method.mustache b/templates/dart/guides/method.mustache deleted file mode 100644 index bb3b6320fb..0000000000 --- a/templates/dart/guides/method.mustache +++ /dev/null @@ -1,45 +0,0 @@ -// {{generationBanner}} -// >IMPORT -{{> snippets/import}} -// IMPORT< - -{{#blocksRequests}} -{{#snippets}} -// Snippet for the {{{method}}} method. -// -// {{{description}}} -void snippetFor{{method}}{{testIndex}}() async { - // >SEPARATOR {{method}} {{{testName}}} - // Initialize the client - {{> snippets/init}} - - // Call the API - {{#hasResponse}}final response = {{/hasResponse}}{{#isAsyncMethod}}await {{/isAsyncMethod}}client.{{method}}( - {{#parametersWithDataType}} - {{> tests/request_param}} - {{/parametersWithDataType}} - {{#hasRequestOptions}} - requestOptions : RequestOptions( - {{#requestOptions.headers}} - headers: { - {{#parametersWithDataType}} - '{{{key}}}' : '{{value}}', - {{/parametersWithDataType}} - }, - {{/requestOptions.headers}} - {{#requestOptions.queryParameters}} - urlParameters: { - {{#parametersWithDataType}} - '{{{key}}}' : {{> tests/param_value}}, - {{/parametersWithDataType}} - }, - {{/requestOptions.queryParameters}} - ), - {{/hasRequestOptions}} - ); - // >LOG - // SEPARATOR< -} - -{{/snippets}} -{{/blocksRequests}} \ No newline at end of file diff --git a/templates/dart/guides/pubspec.mustache b/templates/dart/guides/pubspec.mustache deleted file mode 100644 index 966755ca0d..0000000000 --- a/templates/dart/guides/pubspec.mustache +++ /dev/null @@ -1,16 +0,0 @@ -name: algolia_snippets -version: 1.0.0 - -environment: - sdk: ^3.0.0 - -dependencies: - algoliasearch: ^1.0.0 - algolia_client_search: ^1.0.0 - algolia_client_insights: ^1.0.0 - algolia_client_recommend: ^1.0.0 - dotenv: ^4.1.0 - http: ^1.2.2 - -dev_dependencies: - lints: ^5.0.0 diff --git a/templates/dart/guides/pubspec_overrides.mustache b/templates/dart/guides/pubspec_overrides.mustache deleted file mode 100644 index 8186223507..0000000000 --- a/templates/dart/guides/pubspec_overrides.mustache +++ /dev/null @@ -1,11 +0,0 @@ -dependency_overrides: - algoliasearch: - path: ../../../clients/algoliasearch-client-dart/packages/algoliasearch - algolia_client_core: - path: ../../../clients/algoliasearch-client-dart/packages/client_core - algolia_client_search: - path: ../../../clients/algoliasearch-client-dart/packages/client_search - algolia_client_insights: - path: ../../../clients/algoliasearch-client-dart/packages/client_insights - algolia_client_recommend: - path: ../../../clients/algoliasearch-client-dart/packages/client_recommend \ No newline at end of file diff --git a/templates/dart/snippets/pubspec.mustache b/templates/dart/snippets/pubspec.mustache index b23129b2be..7cad2f8667 100644 --- a/templates/dart/snippets/pubspec.mustache +++ b/templates/dart/snippets/pubspec.mustache @@ -10,6 +10,7 @@ dependencies: algolia_client_insights: ^1.0.0 algolia_client_recommend: ^1.0.0 dotenv: ^4.1.0 + http: ^1.2.2 dev_dependencies: - lints: ^5.0.0 + lints: ^5.0.0 \ No newline at end of file From 7cf091e1ad1dee56a3347572c44de68ad62f2639 Mon Sep 17 00:00:00 2001 From: shortcuts Date: Tue, 26 Nov 2024 10:00:51 +0100 Subject: [PATCH 11/11] chore: cache? --- .github/workflows/check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index d520857dd4..6597f49b94 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -41,7 +41,7 @@ jobs: runs-on: ubuntu-22.04 timeout-minutes: 10 env: - CACHE_VERSION: 1.11 # bump this to run all clients on the CI. + CACHE_VERSION: 1.12 # bump this to run all clients on the CI. steps: - name: debugging - dump GitHub context env: