diff --git a/. travis.yml b/. travis.yml index aabc0ac..b73a5da 100644 --- a/. travis.yml +++ b/. travis.yml @@ -9,4 +9,4 @@ dart_task: - pub global activate remove_from_coverage - pub global run remove_from_coverage:remove_from_coverage -f coverage/lcov.info -r '.g.dart$' - genhtml -o coverage coverage/lcov.info - - open coverage/index.html \ No newline at end of file + - open coverage/index.html diff --git a/.dccache b/.dccache new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/.dccache @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..e5e0c89 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,17 @@ +# .github/workflows/publish.yml +name: Publish to pub.dev + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+*' # tag-pattern on pub.dev: 'v{{version}}' + +# Publish using the reusable workflow from dart-lang. +jobs: + publish: + permissions: + id-token: write # Required for authentication using OIDC + uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1 + with: + environment: 'pub.dev' + working-directory: . diff --git a/.talismanrc b/.talismanrc new file mode 100644 index 0000000..40dce16 --- /dev/null +++ b/.talismanrc @@ -0,0 +1,4 @@ +fileignoreconfig: +- filename: pubspec.lock + checksum: d37af197ed50d9896ef5e9e6c4ad4961c11c2c49765e7cb4f4b69695fa562aa5 +version: "" diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..e5caf58 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,10 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "contentstack-dart", + "request": "launch", + "type": "dart" + } + ] +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 98d19f2..287de2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +## v0.5.1 - Added support for gcp_na region +#### Added support for gcp_na region + ## v0.5.0 - Multiple-reference issue fixed ### **MAR-16-2022** diff --git a/LICENSE b/LICENSE index 2d686e4..283fb4a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,6 @@ -MIT License - -Copyright (c) 2012 - 2021 Contentstack. All rights reserved. +# MIT License +Copyright (c) 2012 - 2024 Contentstack. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 3ab2edc..252c606 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ - # ![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png) ## Dart SDK for Contentstack @@ -8,6 +7,8 @@ ![Dart CI](https://github.com/contentstack/contentstack-dart/workflows/Dart%20CI/badge.svg) ![dartdoc](https://img.shields.io/badge/dartdoc-latest-.svg) + + ![issues](https://img.shields.io/github/issues/contentstack/contentstack-dart) ![fork](https://img.shields.io/github/forks/contentstack/contentstack-dart) ![starts](https://img.shields.io/github/stars/contentstack/contentstack-dart) @@ -71,9 +72,9 @@ Learn how to work with [Environments](https://www.contentstack.com/docs/develope ### Contentstack Dart SDK: 5-minute Quickstart -#### __Initializing your SDK__ +#### **Initializing your SDK** -To initialize the SDK, specify application API key, access token, and environment name of the stack +To initialize the SDK, specify application API key, access token, and environment name of the stack as shown in the snippet given below (config is optional): ```dart diff --git a/coverage.json b/coverage.json new file mode 100644 index 0000000..e69de29 diff --git a/example/example.md b/example/example.md index dcba0dd..f170b6f 100644 --- a/example/example.md +++ b/example/example.md @@ -1,4 +1,3 @@ - # Contentstack Examples ## Developer's Guide @@ -50,7 +49,10 @@ flutter pub get Now in your dart or flutter code, you can use + ``` + import 'package:contentstack/contentstack.dart' as contentstack; + ``` ### Initialize SDK @@ -61,7 +63,7 @@ import 'package:contentstack/contentstack.dart' as contentstack; final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); ``` -## Initialize by configuration +## Initialize by configuration ```dart import 'package:contentstack/contentstack.dart' as contentstack; @@ -169,3 +171,4 @@ await assetQuery.find, Null>().then((response) { }).catchError((error) { print(error.message.toString()); }); +``` diff --git a/lib/client.dart b/lib/client.dart index e9d3fed..6dd72fb 100644 --- a/lib/client.dart +++ b/lib/client.dart @@ -56,14 +56,21 @@ class HttpClient extends http.BaseClient { } else if (T == SyncResult && bodyJson.containsKey('items')) { return fromJson(bodyJson); } else { + if (bodyJson.containsKey('entries')) { + var previewResponse = stack.livePreview['entries']; + if (previewResponse != null) { + return fromJson(mergeLivePreview(bodyJson, previewResponse)); + } + } return fromJson(bodyJson); } } else { - // Response code other than 200 return bodyJson; } } + mergeLivePreview(Map bodyJson, Map previewResponse) {} + /// Generic objects as well as List of generic objects /// (from a JSON list response). /// First, you need to have a function that checks the type of the diff --git a/lib/src/asset_query.dart b/lib/src/asset_query.dart index c7db0d5..75a4044 100644 --- a/lib/src/asset_query.dart +++ b/lib/src/asset_query.dart @@ -134,7 +134,6 @@ class AssetQuery extends BaseQuery { queryParameter['version'] = version.toString(); } - /// /// Includes branch in the response /// diff --git a/lib/src/contenttype.dart b/lib/src/contenttype.dart index 291ac20..adeaa34 100644 --- a/lib/src/contenttype.dart +++ b/lib/src/contenttype.dart @@ -23,7 +23,6 @@ class ContentType { } } - /// /// This function provide option to get single entry as well as /// all the entries. [entryUid] is Optional, If [entryUid] diff --git a/lib/src/entry_queryable.dart b/lib/src/entry_queryable.dart index 43cd401..7c69d54 100644 --- a/lib/src/entry_queryable.dart +++ b/lib/src/entry_queryable.dart @@ -81,7 +81,7 @@ class EntryQueryable { /// includeEmbeddedItems instance of Entry /// Include Embedded Objects (Entries and Assets) along with entry/entries details /// - /// [Example for Entry class] + /// Example: /// ``` /// final stack = contentstack.Stack('apiKey','deliveryToken','environment'); /// final entry = stack.contentType("contentTypeUid").entry("entryUid"); @@ -93,8 +93,8 @@ class EntryQueryable { } /// - /// Includes branch in the response - /// [Example for Entry class] + /// Includes branch in the Entry response + /// Example: /// ``` /// final stack = contentstack.Stack('apiKey','deliveryToken','environment'); /// final entry = stack.contentType("contentTypeUid").entry("entryUid"); @@ -205,7 +205,6 @@ class EntryQueryable { }); } else { parameter['include[]'] = referenceFieldUid; - print('We are in multiple references'); } } } diff --git a/lib/src/image_transform.dart b/lib/src/image_transform.dart index cbdd3bd..2d514ec 100644 --- a/lib/src/image_transform.dart +++ b/lib/src/image_transform.dart @@ -120,34 +120,34 @@ class ImageTransformation { /// the canvas area or offset the canvas on its X and Y axis. /// /// [canvasValue] could be in the type of string, - /// It could be in the format of dimension: [700,800] - /// ratio: 2:3 , sub-region: [700,800,x0.50,y0.60], - /// or offset :[ 700,800,offset-x0.65,offset-y0.80] + /// It could be in the format of dimension: '700','800' + /// ratio: 2:3 , sub-region: '700','800','x0.50','y0.60', + /// or offset : '700','800','offset-x0.65','offset-y0.80' /// For more details, Read documentation: /// https://www.contentstack.com/docs/developers/apis/image-delivery-api/#canvas /// /// Example: Canvas by width & Height: /// /// ```dart - /// final stack = contentstack.Stack(apiKey, deliveryToken, environment); + /// final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment'); /// final imageTransformation = stack.imageTransform(imageUrl); - /// final response = imageTransformation.canvas('700,800'); + /// final response = imageTransformation.canvas('700','800'); /// ``` /// /// Example: Canvas by ratio: /// /// ```dart - /// final stack = contentstack.Stack(apiKey, deliveryToken, environment); - /// final imageTransformation = stack.imageTransform(imageUrl); + /// final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment'); + /// final imageTransformation = stack.imageTransform('imageUrl'); /// final response = imageTransformation.canvas('2:3'); /// ``` /// /// Example: Canvas Sub-region: /// /// ```dart - /// final stack = contentstack.Stack(apiKey, deliveryToken, environment); + /// final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment'); /// final imageTransformation = stack.imageTransform(imageUrl); - /// final response = imageTransformation.canvas('700,800,x0.50,y0.60'); + /// final response = imageTransformation.canvas('700','800','x0.50','y0.60'); /// ``` /// /// Example: Canvas and offset: @@ -155,8 +155,7 @@ class ImageTransformation { /// ```dart /// final stack = contentstack.Stack(apiKey, deliveryToken, environment); /// final imageTransformation = stack.imageTransform(imageUrl); - /// final response = imageTransformation. - /// canvas('700,800,offset-x0.65,offset-y0.80'); + /// final response = imageTransformation.canvas('700','800','offset-x0.65','offset-y0.80'); /// ``` /// void canvas(String canvasValue) { diff --git a/lib/src/query.dart b/lib/src/query.dart index d60c2cc..0c4f3ad 100644 --- a/lib/src/query.dart +++ b/lib/src/query.dart @@ -137,9 +137,9 @@ class Query extends BaseQuery { /// includeEmbeddedItems instance of Query /// Include Embedded Objects (Entries and Assets) along with entry/entries details /// - /// [Example for Entry class] + /// Example: /// ``` - /// final stack = contentstack.Stack('apiKey, 'deliveryKey, 'environment); + /// final stack = contentstack.Stack('apiKey', 'deliveryKey', 'environment'); /// final query = stack.contentType('contentTypeUid').entry().query(); /// query = query.includeEmbeddedItems() /// ``` diff --git a/lib/src/stack.dart b/lib/src/stack.dart index 314ce5a..9209e26 100644 --- a/lib/src/stack.dart +++ b/lib/src/stack.dart @@ -1,16 +1,18 @@ import 'dart:async'; +import 'dart:convert'; import 'package:contentstack/client.dart'; import 'package:contentstack/contentstack.dart'; import 'package:contentstack/src/asset_query.dart'; import 'package:contentstack/src/sync/publishtype.dart'; +import 'package:http/http.dart' as http; import 'package:http/http.dart'; /// Choosing a Region /// A Contentstack region refers to the location of the data centers /// where your organization's data resides /// * Default [Region](https://www.contentstack.com/docs/developers/contentstack-regions/about-regions/) is: US -enum Region { us, eu, azure_na } +enum Region { us, eu, azure_na, gcp_na } /// A stack is like a container that holds the content of your app. /// Learn more about [Stacks](https://www.contentstack.com/docs/developers/set-up-stack/about-stack/). @@ -78,6 +80,9 @@ class Stack { _host = 'azure-na.contentstack.com'; } } + if (region == Region.gcp_na) { + _host = 'gcp-na-cdn.contentstack.com'; + } if (_apiKey.replaceAll(RegExp('\\W'), '').isEmpty ?? true) { throw ArgumentError.notNull('apiKey'); @@ -234,7 +239,7 @@ class Stack { /// Fetches all Content Types from the Stack. /// This call returns comprehensive information /// of all the content types available in a particular stack in your account. - /// API Reference: https://www.contentstack.com/docs/apis/content-delivery-api/#content-types + /// API Reference: https://www.contentstack.com/docs/developers/apis/content-delivery-api/#content-types /// [queryParameters] is query parameters for the content_types of type [Map] /// returns list of content_types /// @@ -432,18 +437,70 @@ class Stack { if (livePreview.containsKey('enable')) { final bool enable = livePreview['enable'] as bool; if (enable) { - if (livePreviewQuery.containsKey('live_preview') && - livePreviewQuery['live_preview'] != null) { - livePreview['live_preview'] = livePreviewQuery['live_preview']; - } else { - livePreview['live_preview'] = 'init'; - } if (livePreviewQuery.containsKey('content_type_uid') && livePreviewQuery['content_type_uid'] != null) { - livePreview['content_type_uid'] = - livePreviewQuery['content_type_uid']; + var content_type_uid = livePreviewQuery['content_type_uid']; + var _entry_uid = livePreviewQuery['entry_uid']; + var _host = livePreviewQuery['host']; + _executeAPI(content_type_uid, _entry_uid, _host); } } } } + + Future _executeAPI(content_type_uid, entry_uid, host) async { + var _url = + "https://$host}/${this.apiVersion}/content_types/$content_type_uid/entries/$entry_uid"; + var _headers = { + 'authorization': headers['authorization'], + 'api_key': headers['api_key'], + }; + + await http.get(Uri.parse(_url), headers: _headers).then((response) { + Map bodyJson = json.decode(utf8.decode(response.bodyBytes)); + print(bodyJson); + livePreview["entry"] = bodyJson['entry']; + }); + } + + /// + /// + /// All Global Fields + /// + /// All global fields + /// This call returns comprehensive information of all the global fields + /// savailable in a particular stack in your account. + /// + /// ``` + /// var response = stack.globalField(); + /// ``` + + /// Single Global Field + /// Get a single global field + /// + /// This request allows you to fetch comprehensive details of a specific + /// global field.When executing the API call, in the 'URI Parameters' section, + /// provide the unique ID of your global field. + /// ``` + /// var response = stack.globalField('sso'); + /// ``` + /// include_branch (optional) + /// ``` + /// var response = stack.globalField('sso', true); + /// ``` + + Future globalField( + [String globalFieldUid, bool includeBranch = false]) { + final parameters = {}; + parameters['environment'] = _client.stackHeaders['environment']; + if (includeBranch) { + parameters['include_branch'] = true.toString(); + } + Uri uri = Uri.https(endpoint, '$apiVersion/global_fields', parameters); + if (globalFieldUid != null && globalFieldUid.isNotEmpty) { + uri = Uri.https( + endpoint, '$apiVersion/global_fields/$globalFieldUid', parameters); + } + return _client.sendRequest(uri); + } } diff --git a/pubspec.lock b/pubspec.lock index e5733d6..13553ab 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,595 +5,680 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - url: "https://pub.dartlang.org" + sha256: cf8fb49539ecd6fea20ce18f2f858b88f8c27d4e7e3c09e1c6ed3289552bf223 + url: "https://pub.dev" source: hosted version: "36.0.0" analyzer: dependency: transitive description: name: analyzer - url: "https://pub.dartlang.org" + sha256: "45ebaf3b2fc49c371de62c5ec855207f0503a41f94bd92ae50d7320fdf28accd" + url: "https://pub.dev" source: hosted version: "3.3.1" archive: dependency: transitive description: name: archive - url: "https://pub.dartlang.org" + sha256: cdecf5f45a132ba5671845ec126269a17a69979c0f385852ad4a7d8639016441 + url: "https://pub.dev" source: hosted version: "3.2.2" args: dependency: transitive description: name: args - url: "https://pub.dartlang.org" + sha256: "0bd9a99b6eb96f07af141f0eb53eace8983e8e5aa5de59777aca31684680ef22" + url: "https://pub.dev" source: hosted version: "2.3.0" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: db4766341bd8ecb66556f31ab891a5d596ef829221993531bd64a8e6342f0cda + url: "https://pub.dev" source: hosted version: "2.8.2" bazel_worker: dependency: transitive description: name: bazel_worker - url: "https://pub.dartlang.org" + sha256: b0f16544323bfc3ba1d879e6b65eee07508009023d51e89978f261cf9853187f + url: "https://pub.dev" source: hosted version: "1.0.1" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "5bbf32bc9e518d41ec49718e2931cd4527292c9b0c6d2dffcf7fe6b9a8a8cf72" + url: "https://pub.dev" source: hosted version: "2.1.0" build: dependency: transitive description: name: build - url: "https://pub.dartlang.org" + sha256: c9b6c412967d7887e88efe1ffbfe0f31bfaf6a5a4b98eb8d59964977a90f2f9e + url: "https://pub.dev" source: hosted version: "2.2.1" build_config: dependency: transitive description: name: build_config - url: "https://pub.dartlang.org" + sha256: ad77deb6e9c143a3f550fbb4c5c1e0c6aadabe24274898d06b9526c61b9cf4fb + url: "https://pub.dev" source: hosted version: "1.0.0" build_daemon: dependency: transitive description: name: build_daemon - url: "https://pub.dartlang.org" + sha256: "4e2dbfa914f99bca9c447ba5aaa572edf7335a71717944e4ab2e26ca079e7f79" + url: "https://pub.dev" source: hosted version: "3.0.1" build_modules: dependency: transitive description: name: build_modules - url: "https://pub.dartlang.org" + sha256: ca9167159cf798e42b1d046acdc9757c01fe8e6f93f5412707a7f7a02c7f391c + url: "https://pub.dev" source: hosted version: "4.0.4" build_resolvers: dependency: transitive description: name: build_resolvers - url: "https://pub.dartlang.org" + sha256: "4666aef1d045c5ca15ebba63e400bd4e4fbd9f0dd06e791b51ab210da78a27f7" + url: "https://pub.dev" source: hosted version: "2.0.6" build_runner: dependency: "direct dev" description: name: build_runner - url: "https://pub.dartlang.org" + sha256: e090beee726671ff68747cb4d8c9151704864ec9a5dc88db9fe6441c24b3fa55 + url: "https://pub.dev" source: hosted version: "2.1.7" build_runner_core: dependency: transitive description: name: build_runner_core - url: "https://pub.dartlang.org" + sha256: f4d6244cc071ba842c296cb1c4ee1b31596b9f924300647ac7a1445493471a3f + url: "https://pub.dev" source: hosted version: "7.2.3" build_test: dependency: "direct dev" description: name: build_test - url: "https://pub.dartlang.org" + sha256: b8165c422fab3f04622f44942ba0d85c7a0a1dd8195badce6862b24d19acd945 + url: "https://pub.dev" source: hosted version: "2.1.5" build_web_compilers: dependency: "direct dev" description: name: build_web_compilers - url: "https://pub.dartlang.org" + sha256: "12f99028bb4bef837b2b00b3e8afdbe922718acb249208d6a15c17fcdb79f983" + url: "https://pub.dev" source: hosted version: "3.2.2" built_collection: dependency: transitive description: name: built_collection - url: "https://pub.dartlang.org" + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" source: hosted version: "5.1.1" built_value: dependency: transitive description: name: built_value - url: "https://pub.dartlang.org" + sha256: b6c9911b2d670376918d5b8779bc27e0e612a94ec3ff0343689e991d8d0a3b8a + url: "https://pub.dev" source: hosted version: "8.1.4" charcode: dependency: transitive description: name: charcode - url: "https://pub.dartlang.org" + sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 + url: "https://pub.dev" source: hosted version: "1.3.1" checked_yaml: dependency: transitive description: name: checked_yaml - url: "https://pub.dartlang.org" + sha256: dd007e4fb8270916820a0d66e24f619266b60773cddd082c6439341645af2659 + url: "https://pub.dev" source: hosted version: "2.0.1" cli_util: dependency: transitive description: name: cli_util - url: "https://pub.dartlang.org" + sha256: "66f86e916d285c1a93d3b79587d94bd71984a66aac4ff74e524cfa7877f1395c" + url: "https://pub.dev" source: hosted version: "0.3.5" code_builder: dependency: transitive description: name: code_builder - url: "https://pub.dartlang.org" + sha256: bdb1ab29be158c4784d7f9b7b693745a0719c5899e31c01112782bb1cb871e80 + url: "https://pub.dev" source: hosted version: "4.1.0" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: ef7e3a5529178ce8f37a9d0b11cbbc8b1e025940f9cf9f76c42da6796301219d + url: "https://pub.dev" source: hosted version: "1.16.0" convert: dependency: transitive description: name: convert - url: "https://pub.dartlang.org" + sha256: f08428ad63615f96a27e34221c65e1a451439b5f26030f78d790f461c686d65d + url: "https://pub.dev" source: hosted version: "3.0.1" coverage: dependency: transitive description: name: coverage - url: "https://pub.dartlang.org" + sha256: c0122af6b3548369d6b7830c7a140d85c9a988d8d29c4976aa9ce4de46b122ef + url: "https://pub.dev" source: hosted version: "1.1.0" crypto: dependency: transitive description: name: crypto - url: "https://pub.dartlang.org" + sha256: cf75650c66c0316274e21d7c43d3dea246273af5955bd94e8184837cd577575c + url: "https://pub.dev" source: hosted version: "3.0.1" csslib: dependency: transitive description: name: csslib - url: "https://pub.dartlang.org" + sha256: d1cd6d6e4b39a4ad295204722b8608f19981677b223f3e942c0b5a33dcf57ec0 + url: "https://pub.dev" source: hosted version: "0.17.1" dart_style: dependency: transitive description: name: dart_style - url: "https://pub.dartlang.org" + sha256: "959d3de27b5e0713f954643ee38619551da06e61e08088968fe7e1eb0cd720b1" + url: "https://pub.dev" source: hosted version: "2.2.2" dartdoc: dependency: "direct main" description: name: dartdoc - url: "https://pub.dartlang.org" + sha256: "473f65994b03884823e80cf30d732d9dd42e049d4a4b2b8ff484a33db8375de7" + url: "https://pub.dev" source: hosted version: "5.0.1" dotenv: dependency: "direct main" description: name: dotenv - url: "https://pub.dartlang.org" + sha256: dc4c91d8d5e9e361803fc81e8ea7ba0f35be483b656837ea6b9a3c41df308c68 + url: "https://pub.dev" source: hosted version: "3.0.0" equatable: dependency: transitive description: name: equatable - url: "https://pub.dartlang.org" + sha256: "8007a033720c056066dd1dc20bc2934cac91e271f0408c578aa26c7731618a03" + url: "https://pub.dev" source: hosted version: "1.2.6" file: dependency: transitive description: name: file - url: "https://pub.dartlang.org" + sha256: b69516f2c26a5bcac4eee2e32512e1a5205ab312b3536c1c1227b2b942b5f9ad + url: "https://pub.dev" source: hosted version: "6.1.2" fixnum: dependency: transitive description: name: fixnum - url: "https://pub.dartlang.org" + sha256: "6a2ef17156f4dc49684f9d99aaf4a93aba8ac49f5eac861755f5730ddf6e2e4e" + url: "https://pub.dev" source: hosted version: "1.0.0" flutter_lints: dependency: "direct dev" description: name: flutter_lints - url: "https://pub.dartlang.org" + sha256: b543301ad291598523947dc534aaddc5aaad597b709d2426d3a0e0d44c5cb493 + url: "https://pub.dev" source: hosted version: "1.0.4" frontend_server_client: dependency: transitive description: name: frontend_server_client - url: "https://pub.dartlang.org" + sha256: "6d2930621b9377f6a4b7d260fce525d48dd77a334f0d5d4177d07b0dcb76c032" + url: "https://pub.dev" source: hosted version: "2.1.2" glob: dependency: transitive description: name: glob - url: "https://pub.dartlang.org" + sha256: "8321dd2c0ab0683a91a51307fa844c6db4aa8e3981219b78961672aaab434658" + url: "https://pub.dev" source: hosted version: "2.0.2" graphs: dependency: transitive description: name: graphs - url: "https://pub.dartlang.org" + sha256: ae0b3d956ff324c6f8671f08dcb2dbd71c99cdbf2aa3ca63a14190c47aa6679c + url: "https://pub.dev" source: hosted version: "2.1.0" html: dependency: transitive description: name: html - url: "https://pub.dartlang.org" + sha256: bfef906cbd4e78ef49ae511d9074aebd1d2251482ef601a280973e8b58b51bbf + url: "https://pub.dev" source: hosted version: "0.15.0" http: dependency: "direct main" description: name: http - url: "https://pub.dartlang.org" + sha256: "2ed163531e071c2c6b7c659635112f24cb64ecbebf6af46b550d536c0b1aa112" + url: "https://pub.dev" source: hosted version: "0.13.4" http_multi_server: dependency: transitive description: name: http_multi_server - url: "https://pub.dartlang.org" + sha256: ab298ef2b2acd283bd36837df7801dcf6e6b925f8da6e09efb81111230aa9037 + url: "https://pub.dev" source: hosted version: "3.2.0" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: e362d639ba3bc07d5a71faebb98cde68c05bfbcfbbb444b60b6f60bb67719185 + url: "https://pub.dev" source: hosted version: "4.0.0" io: dependency: transitive description: name: io - url: "https://pub.dartlang.org" + sha256: "0d4c73c3653ab85bf696d51a9657604c900a370549196a91f33e4c39af760852" + url: "https://pub.dev" source: hosted version: "1.0.3" js: dependency: transitive description: name: js - url: "https://pub.dartlang.org" + sha256: a5e201311cb08bf3912ebbe9a2be096e182d703f881136ec1e81a2338a9e120d + url: "https://pub.dev" source: hosted version: "0.6.4" json_annotation: dependency: "direct main" description: name: json_annotation - url: "https://pub.dartlang.org" + sha256: "2639efc0237c7b71c6584696c0847ea4e4733ddaf571ae9c79d5295e8ae17272" + url: "https://pub.dev" source: hosted version: "4.4.0" json_serializable: dependency: "direct dev" description: name: json_serializable - url: "https://pub.dartlang.org" + sha256: a53cf24d6fcb43661c31c3eb43dd1832b71abc8b62afa59be909416140a08610 + url: "https://pub.dev" source: hosted version: "6.1.5" lints: dependency: transitive description: name: lints - url: "https://pub.dartlang.org" + sha256: a2c3d198cb5ea2e179926622d433331d8b58374ab8f29cdda6e863bd62fd369c + url: "https://pub.dev" source: hosted version: "1.0.1" logger: dependency: "direct main" description: name: logger - url: "https://pub.dartlang.org" + sha256: "5076f09225f91dc49289a4ccb92df2eeea9ea01cf7c26d49b3a1f04c6a49eec1" + url: "https://pub.dev" source: hosted version: "1.1.0" logging: dependency: transitive description: name: logging - url: "https://pub.dartlang.org" + sha256: "293ae2d49fd79d4c04944c3a26dfd313382d5f52e821ec57119230ae16031ad4" + url: "https://pub.dev" source: hosted version: "1.0.2" markdown: dependency: transitive description: name: markdown - url: "https://pub.dartlang.org" + sha256: "01512006c8429f604eb10f9848717baeaedf99e991d14a50d540d9beff08e5c6" + url: "https://pub.dev" source: hosted version: "4.0.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "2e2c34e631f93410daa3ee3410250eadc77ac6befc02a040eda8a123f34e6f5a" + url: "https://pub.dev" source: hosted version: "0.12.11" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "5202fdd37b4da5fd14a237ed0a01cad6c1efd4c99b5b5a0d3c9237f3728c9485" + url: "https://pub.dev" source: hosted version: "1.7.0" mime: dependency: transitive description: name: mime - url: "https://pub.dartlang.org" + sha256: fd5f81041e6a9fc9b9d7fa2cb8a01123f9f5d5d49136e06cb9dc7d33689529f4 + url: "https://pub.dev" source: hosted version: "1.0.1" node_preamble: dependency: transitive description: name: node_preamble - url: "https://pub.dartlang.org" + sha256: "8ebdbaa3b96d5285d068f80772390d27c21e1fa10fb2df6627b1b9415043608d" + url: "https://pub.dev" source: hosted version: "2.0.1" package_config: dependency: transitive description: name: package_config - url: "https://pub.dartlang.org" + sha256: a4d5ede5ca9c3d88a2fef1147a078570c861714c806485c596b109819135bc12 + url: "https://pub.dev" source: hosted version: "2.0.2" path: dependency: "direct main" description: name: path - url: "https://pub.dartlang.org" + sha256: "240ed0e9bd73daa2182e33c4efc68c7dd53c7c656f3da73515a2d163e151412d" + url: "https://pub.dev" source: hosted version: "1.8.1" pool: dependency: transitive description: name: pool - url: "https://pub.dartlang.org" + sha256: "05955e3de2683e1746222efd14b775df7131139e07695dc8e24650f6b4204504" + url: "https://pub.dev" source: hosted version: "1.5.0" protobuf: dependency: transitive description: name: protobuf - url: "https://pub.dartlang.org" + sha256: f9b7809db75bc95d411bc197d714613fb42f0b0c17553c95568a2a9179d2a7ea + url: "https://pub.dev" source: hosted version: "2.0.1" pub_semver: dependency: transitive description: name: pub_semver - url: "https://pub.dartlang.org" + sha256: "816c1a640e952d213ddd223b3e7aafae08cd9f8e1f6864eed304cc13b0272b07" + url: "https://pub.dev" source: hosted version: "2.1.1" pubspec_parse: dependency: transitive description: name: pubspec_parse - url: "https://pub.dartlang.org" + sha256: "3686efe4a4613a4449b1a4ae08670aadbd3376f2e78d93e3f8f0919db02a7256" + url: "https://pub.dev" source: hosted version: "1.2.0" scratch_space: dependency: transitive description: name: scratch_space - url: "https://pub.dartlang.org" + sha256: a469a9642a4d7ee406d6224a85446eb8baa9dd6d81e2f0b76770deae7bd32aab + url: "https://pub.dev" source: hosted version: "1.0.1" shelf: dependency: transitive description: name: shelf - url: "https://pub.dartlang.org" + sha256: c240984c924796e055e831a0a36db23be8cb04f170b26df572931ab36418421d + url: "https://pub.dev" source: hosted version: "1.2.0" shelf_packages_handler: dependency: transitive description: name: shelf_packages_handler - url: "https://pub.dartlang.org" + sha256: e0b44ebddec91e70a713e13adf93c1b2100821303b86a18e1ef1d082bd8bd9b8 + url: "https://pub.dev" source: hosted version: "3.0.0" shelf_static: dependency: transitive description: name: shelf_static - url: "https://pub.dartlang.org" + sha256: "4a0d12cd512aa4fc55fed5f6280f02ef183f47ba29b4b0dfd621b1c99b7e6361" + url: "https://pub.dev" source: hosted version: "1.1.0" shelf_web_socket: dependency: transitive description: name: shelf_web_socket - url: "https://pub.dartlang.org" + sha256: fd84910bf7d58db109082edf7326b75322b8f186162028482f53dc892f00332d + url: "https://pub.dev" source: hosted version: "1.0.1" source_gen: dependency: transitive description: name: source_gen - url: "https://pub.dartlang.org" + sha256: d5aa894fcfa327e19196d6f4f733597a10b42a7e55c8cb2b0dd60d7e7d27dccf + url: "https://pub.dev" source: hosted version: "1.2.1" source_helper: dependency: transitive description: name: source_helper - url: "https://pub.dartlang.org" + sha256: bff606c07bddcabef6b06ad6d90eee3bc5f7adbbf48c2939963145b004b5b8b3 + url: "https://pub.dev" source: hosted version: "1.3.1" source_map_stack_trace: dependency: transitive description: name: source_map_stack_trace - url: "https://pub.dartlang.org" + sha256: "8c463326277f68a628abab20580047b419c2ff66756fd0affd451f73f9508c11" + url: "https://pub.dev" source: hosted version: "2.1.0" source_maps: dependency: transitive description: name: source_maps - url: "https://pub.dartlang.org" + sha256: "52de2200bb098de739794c82d09c41ac27b2e42fd7e23cce7b9c74bf653c7296" + url: "https://pub.dev" source: hosted version: "0.10.10" source_span: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: d77dbb9d0b7469d91e42d352334b2b4bbd5cec4379542f1bdb630db368c4d9f6 + url: "https://pub.dev" source: hosted version: "1.8.2" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: f8d9f247e2f9f90e32d1495ff32dac7e4ae34ffa7194c5ff8fcc0fd0e52df774 + url: "https://pub.dev" source: hosted version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: db47e4797198ee601990820437179bb90219f918962318d494ada2b4b11e6f6d + url: "https://pub.dev" source: hosted version: "2.1.0" stream_transform: dependency: transitive description: name: stream_transform - url: "https://pub.dartlang.org" + sha256: ed464977cb26a1f41537e177e190c67223dbd9f4f683489b6ab2e5d211ec564e + url: "https://pub.dev" source: hosted version: "2.0.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: dd11571b8a03f7cadcf91ec26a77e02bfbd6bbba2a512924d3116646b4198fc4 + url: "https://pub.dev" source: hosted version: "1.1.0" super_enum: dependency: "direct main" description: name: super_enum - url: "https://pub.dartlang.org" + sha256: "4ef073e108450589a813ba92ebd24a391cb74e0e12dcb54e72181d8896b58794" + url: "https://pub.dev" source: hosted version: "0.5.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a88162591b02c1f3a3db3af8ce1ea2b374bd75a7bb8d5e353bcfbdc79d719830 + url: "https://pub.dev" source: hosted version: "1.2.0" test: dependency: "direct dev" description: name: test - url: "https://pub.dartlang.org" + sha256: fd53f3bac5c70f26eec065456f73b20b11ea969aaa1099928bf9a6c1fd0e1403 + url: "https://pub.dev" source: hosted version: "1.20.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: d8ca35bbbeef2d037e5693a3c8a381505afebfbfee7bc33fff5581bc4e16a939 + url: "https://pub.dev" source: hosted version: "0.4.9" test_core: dependency: transitive description: name: test_core - url: "https://pub.dartlang.org" + sha256: cc8bc45cbe52e8133293537ac4cffc4d9b35c93e91481eb64ef2304e2e722949 + url: "https://pub.dev" source: hosted version: "0.4.11" timing: dependency: transitive description: name: timing - url: "https://pub.dartlang.org" + sha256: c386d07d7f5efc613479a7c4d9d64b03710b03cfaa7e8ad5f2bfb295a1f0dfad + url: "https://pub.dev" source: hosted version: "1.0.0" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: "53bdf7e979cfbf3e28987552fd72f637e63f3c8724c9e56d9246942dc2fa36ee" + url: "https://pub.dev" source: hosted version: "1.3.0" vm_service: dependency: transitive description: name: vm_service - url: "https://pub.dartlang.org" + sha256: "5e10b8a57f571c4bc3bc45dddf708141fe10ceb5c1d44652a78e8ff497dc6db8" + url: "https://pub.dev" source: hosted version: "8.2.1" watcher: dependency: transitive description: name: watcher - url: "https://pub.dartlang.org" + sha256: e42dfcc48f67618344da967b10f62de57e04bae01d9d3af4c2596f3712a88c99 + url: "https://pub.dev" source: hosted version: "1.0.1" web_socket_channel: dependency: transitive description: name: web_socket_channel - url: "https://pub.dartlang.org" + sha256: "0c2ada1b1aeb2ad031ca81872add6be049b8cb479262c6ad3c4b0f9c24eaab2f" + url: "https://pub.dev" source: hosted version: "2.1.0" webkit_inspection_protocol: dependency: transitive description: name: webkit_inspection_protocol - url: "https://pub.dartlang.org" + sha256: "5adb6ab8ed14e22bb907aae7338f0c206ea21e7a27004e97664b16c120306f00" + url: "https://pub.dev" source: hosted version: "1.0.0" yaml: dependency: transitive description: name: yaml - url: "https://pub.dartlang.org" + sha256: "3cee79b1715110341012d27756d9bae38e650588acd38d3f3c610822e1337ace" + url: "https://pub.dev" source: hosted version: "3.1.0" sdks: diff --git a/pubspec.yaml b/pubspec.yaml index 6ec4720..281c183 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,11 +1,11 @@ name: contentstack description: Contentstack is a headless CMS with an API-first approach that puts content at the centre. -version: 0.5.0 -homepage: www.contentstack.com +version: 0.5.1 +homepage: https://www.contentstack.com documentation: https://www.contentstack.com/docs/developers/apis/content-delivery-api -api_documentation: https://www.contentstack.com/docs/developers/dart/api-reference environment: + # sdk: ">=2.17.6 <3.0.0" sdk: ">=2.8.1 <3.0.0" dependencies: diff --git a/test/contenttype_test.dart b/test/contenttype_test.dart index b93e7ff..c037b14 100644 --- a/test/contenttype_test.dart +++ b/test/contenttype_test.dart @@ -6,7 +6,6 @@ import 'package:test/test.dart'; void main() { final logger = Logger(printer: PrettyPrinter()); - load(); final apiKey = env['apiKey']; final host = env['host']; @@ -52,4 +51,4 @@ void main() { }); }); }); -} \ No newline at end of file +} diff --git a/test/image_transform_test.dart b/test/image_transform_test.dart index b6cfd6b..ceeb39e 100644 --- a/test/image_transform_test.dart +++ b/test/image_transform_test.dart @@ -17,8 +17,7 @@ void main() { final Stack stack = Stack(apiKey, deliveryToken, environment, host: host); group('ImageTransformation functional testcases', () { - const imageUrl = - 'https://images.contentstack.io/v3/assets/download'; + const imageUrl = 'https://images.contentstack.io/v3/assets/download'; ImageTransformation imageTransformation; setUp(() { diff --git a/test/query_test.dart b/test/query_test.dart index b88770d..699b931 100644 --- a/test/query_test.dart +++ b/test/query_test.dart @@ -214,7 +214,7 @@ void main() { query.where('title', QueryOperation.excludes(value: arrayValue)); await query.find().then((response) { final queryMap = response['entries'].length; - expect(queryMap!=null, true); + expect(queryMap != null, true); }); }); }); @@ -237,7 +237,7 @@ void main() { final includeList = ['Room 13', 'Room 18', 'Room 19']; query.where('title', QueryOperation.includes(value: includeList)); await query.find().then((response) { - expect(response['entries']!=null, true); + expect(response['entries'] != null, true); }).catchError((onError) { expect('Error Occurred', onError.message); }); @@ -399,7 +399,7 @@ void main() { await query.find().then((onResponse) async { query.skip(4); await query.find().then((response) { - expect(0, response['entries'].length); + expect(0, response['entries'].length); }); }); }); diff --git a/test/stack_test.dart b/test/stack_test.dart index 43eec70..5a6205a 100644 --- a/test/stack_test.dart +++ b/test/stack_test.dart @@ -15,13 +15,8 @@ void main() { final environment = env['environment']; final branch = 'development'; logger.i('credentials loaded..'); - final Stack stack = Stack( - apiKey, - deliveryToken, - environment, - host: host, - branch: branch - ); + final Stack stack = + Stack(apiKey, deliveryToken, environment, host: host, branch: branch); group('functional testcases for stack', () { test('check stack credentials', () { @@ -32,7 +27,6 @@ void main() { expect(stack.branch, branch); }); - test('Stack initialization with Host', () { final stack = contentstack.Stack('apiKey', 'accessToken', 'environment', host: 'com.contentstack.com'); @@ -117,7 +111,7 @@ void main() { test('testcases content type fetch uid', () async { final contentType = stack.contentType('application_theme'); await contentType.fetch().then((response) { - expect(response['error_code']!=null, true); + expect(response['error_code'] != null, true); }); }); @@ -138,12 +132,11 @@ void main() { await contentType.fetch(params).then((response) { expect(15, response['content_type']['schema'].length); }).catchError((error) { - expect(error!=null, true); + expect(error != null, true); }); }); }); - group('testcase for URLQueryParams', () { test('test query_params', () { final params = URLQueryParams()..append('key', 'value'); @@ -159,5 +152,20 @@ void main() { final url = params.toUrl('cdn.contentstack.io'); expect('cdn.contentstack.io?key1=value1', url); }); + + test('global fields without params', () { + var response = stack.globalField(); + print(response); + }); + + test('Global fields with parameters', () { + var response = stack.globalField('sso', false); + print(response); + }); + + test('Global fields with parameters', () { + var response = stack.globalField('sso', true); + print(response); + }); }); } diff --git a/test/test_synchronizarion.dart b/test/test_synchronizarion.dart index 52a6303..3965009 100644 --- a/test/test_synchronizarion.dart +++ b/test/test_synchronizarion.dart @@ -3,6 +3,7 @@ import 'package:contentstack/src/sync/publishtype.dart'; import 'package:dotenv/dotenv.dart'; import 'package:logger/logger.dart'; import 'package:test/test.dart'; + void main() { final logger = Logger(printer: PrettyPrinter()); @@ -114,6 +115,5 @@ void main() { expect(100, response['items'].length); }); }); - }); -} \ No newline at end of file +}