@plasmicpkgs/plasmic-cms 0.0.26 → 0.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.d.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import { ApiCmsRow, ApiCmsTable } from "./schema";
2
2
  export interface DatabaseConfig {
3
3
  host: string;
4
- projectId: string;
5
- projectApiToken: string;
6
4
  databaseId: string;
5
+ databaseToken: string;
7
6
  locale: string;
8
7
  }
9
8
  export interface QueryParams {
@@ -1,4 +1,5 @@
1
1
  import { CanvasComponentProps, ComponentMeta } from "@plasmicapp/host/registerComponent";
2
+ import { GlobalContextMeta } from "@plasmicapp/host/registerGlobalContext";
2
3
  import React from "react";
3
4
  import { DatabaseConfig, QueryParams } from "./api";
4
5
  import { ApiCmsTable } from "./schema";
@@ -8,7 +9,7 @@ interface FetcherComponentProps {
8
9
  interface CmsCredentialsProviderProps extends DatabaseConfig {
9
10
  children?: React.ReactNode;
10
11
  }
11
- export declare const cmsCredentialsProviderMeta: ComponentMeta<CmsCredentialsProviderProps>;
12
+ export declare const cmsCredentialsProviderMeta: GlobalContextMeta<CmsCredentialsProviderProps>;
12
13
  export declare function CmsCredentialsProvider({ children, ...config }: CmsCredentialsProviderProps): JSX.Element;
13
14
  declare type TablesContextData = {
14
15
  tables?: ApiCmsTable[];
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
+ import registerGlobalContext from "@plasmicapp/host/registerGlobalContext";
1
2
  import registerComponent from "@plasmicapp/host/registerComponent";
2
3
  export declare function registerAll(loader?: {
3
4
  registerComponent: typeof registerComponent;
5
+ registerGlobalContext: typeof registerGlobalContext;
4
6
  }): void;
5
7
  export * from "./components";
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
6
 
7
+ var registerGlobalContext = _interopDefault(require('@plasmicapp/host/registerGlobalContext'));
7
8
  var registerComponent = _interopDefault(require('@plasmicapp/host/registerComponent'));
8
9
  var host = require('@plasmicapp/host');
9
10
  var query = require('@plasmicapp/query');
@@ -986,7 +987,7 @@ var API = /*#__PURE__*/function () {
986
987
  method: "GET",
987
988
  headers: {
988
989
  accept: "*/*",
989
- "x-plasmic-api-project-tokens": this.config.projectId + ":" + this.config.projectApiToken
990
+ "x-plasmic-api-cms-tokens": this.config.databaseId + ":" + this.config.databaseToken
990
991
  },
991
992
  mode: "cors"
992
993
  });
@@ -1415,9 +1416,7 @@ function renderMaybeData(maybeData, renderFn, loaderProps) {
1415
1416
  return renderFn(maybeData.data);
1416
1417
  }
1417
1418
 
1418
- var defaultHost = "https://studio.plasmic.app"; // TODO: Remove `children` from props and make cmsDataProviderMeta a
1419
- // ContextMeta.
1420
-
1419
+ var defaultHost = "https://studio.plasmic.app";
1421
1420
  var cmsCredentialsProviderMeta = {
1422
1421
  name: componentPrefix + "-credentials-provider",
1423
1422
  displayName: "CMS Credentials Provider",
@@ -1434,29 +1433,17 @@ var cmsCredentialsProviderMeta = {
1434
1433
  databaseId: {
1435
1434
  type: "string",
1436
1435
  displayName: "CMS ID",
1437
- description: "The ID of the CMS (database) to use."
1438
- },
1439
- projectId: {
1440
- type: "string",
1441
- displayName: "Project ID",
1442
- description: "This project's ID."
1436
+ description: "The ID of the CMS (database) to use. (Can get on the CMS settings page)"
1443
1437
  },
1444
- projectApiToken: {
1438
+ databaseToken: {
1445
1439
  type: "string",
1446
- displayName: "Project API token",
1447
- description: "This project's API token."
1440
+ displayName: "CMS Public Token",
1441
+ description: "The Public Token of the CMS (database) you are using. (Can get on the CMS settings page)"
1448
1442
  },
1449
1443
  locale: {
1450
1444
  type: "string",
1451
1445
  displayName: "Locale",
1452
1446
  description: "The locale to use for localized values, leave empty for the default locale."
1453
- },
1454
- children: {
1455
- type: "slot",
1456
- defaultValue: {
1457
- type: "vbox",
1458
- children: []
1459
- }
1460
1447
  }
1461
1448
  }
1462
1449
  };
@@ -1470,12 +1457,8 @@ function CmsCredentialsProvider(_ref) {
1470
1457
  throw new Error("You must specify the CMS database ID to use.");
1471
1458
  }
1472
1459
 
1473
- if (!config.projectId) {
1474
- throw new Error("You must specify the project you are using this CMS from.");
1475
- }
1476
-
1477
- if (!config.projectApiToken) {
1478
- throw new Error("You must specify the token of the project you are using this CMS from.");
1460
+ if (!config.databaseToken) {
1461
+ throw new Error("You must specify the token of the CMS database you are using.");
1479
1462
  }
1480
1463
 
1481
1464
  return React.createElement(DatabaseProvider, {
@@ -2193,7 +2176,15 @@ function registerAll(loader) {
2193
2176
  }
2194
2177
  };
2195
2178
 
2196
- _registerComponent(CmsCredentialsProvider, cmsCredentialsProviderMeta);
2179
+ var _registerGlobalContext = function _registerGlobalContext(Component, defaultMeta) {
2180
+ if (loader) {
2181
+ loader.registerGlobalContext(Component, defaultMeta);
2182
+ } else {
2183
+ registerGlobalContext(Component, defaultMeta);
2184
+ }
2185
+ };
2186
+
2187
+ _registerGlobalContext(CmsCredentialsProvider, cmsCredentialsProviderMeta);
2197
2188
 
2198
2189
  _registerComponent(CmsQueryLoader, cmsQueryLoaderMeta);
2199
2190