@zenstackhq/sdk 0.6.0-pre.2 → 1.0.0-alpha.20

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/constants.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Auxiliary database field for supporting policy check for nested writes
3
+ */
4
+ export declare const TRANSACTION_FIELD_NAME = "zenstack_transaction";
5
+ /**
6
+ * Auxiliary database field for building up policy check queries
7
+ */
8
+ export declare const GUARD_FIELD_NAME = "zenstack_guard";
9
+ /**
10
+ * All Auxiliary fields.
11
+ */
12
+ export declare const AUXILIARY_FIELDS: string[];
package/constants.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AUXILIARY_FIELDS = exports.GUARD_FIELD_NAME = exports.TRANSACTION_FIELD_NAME = void 0;
4
+ /**
5
+ * Auxiliary database field for supporting policy check for nested writes
6
+ */
7
+ exports.TRANSACTION_FIELD_NAME = 'zenstack_transaction';
8
+ /**
9
+ * Auxiliary database field for building up policy check queries
10
+ */
11
+ exports.GUARD_FIELD_NAME = 'zenstack_guard';
12
+ /**
13
+ * All Auxiliary fields.
14
+ */
15
+ exports.AUXILIARY_FIELDS = [exports.TRANSACTION_FIELD_NAME, exports.GUARD_FIELD_NAME];
16
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,sBAAsB,GAAG,sBAAsB,CAAC;AAE7D;;GAEG;AACU,QAAA,gBAAgB,GAAG,gBAAgB,CAAC;AAEjD;;GAEG;AACU,QAAA,gBAAgB,GAAG,CAAC,8BAAsB,EAAE,wBAAgB,CAAC,CAAC"}
package/index.d.ts CHANGED
@@ -1,12 +1,3 @@
1
- import { Model } from '@zenstackhq/language/ast';
2
- import { DMMF } from '@prisma/generator-helper';
3
- export type OptionValue = string | number | boolean;
4
- export type PluginOptions = {
5
- provider?: string;
6
- } & Record<string, OptionValue | OptionValue[]>;
7
- export type PluginFunction = (model: Model, options: PluginOptions, dmmf?: DMMF.Document) => Promise<string[]> | string[] | Promise<void> | void;
8
- export declare class PluginError extends Error {
9
- constructor(message: string);
10
- }
11
- export declare const GUARD_FIELD_NAME = "zenstack_guard";
12
- export declare const TRANSACTION_FIELD_NAME = "zenstack_transaction";
1
+ export * from './constants';
2
+ export * from './types';
3
+ export * from './utils';
package/index.js CHANGED
@@ -1,12 +1,20 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TRANSACTION_FIELD_NAME = exports.GUARD_FIELD_NAME = exports.PluginError = void 0;
4
- class PluginError extends Error {
5
- constructor(message) {
6
- super(message);
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
7
  }
8
- }
9
- exports.PluginError = PluginError;
10
- exports.GUARD_FIELD_NAME = 'zenstack_guard';
11
- exports.TRANSACTION_FIELD_NAME = 'zenstack_transaction';
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./constants"), exports);
18
+ __exportStar(require("./types"), exports);
19
+ __exportStar(require("./utils"), exports);
12
20
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAgBA,MAAa,WAAY,SAAQ,KAAK;IAClC,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;IACnB,CAAC;CACJ;AAJD,kCAIC;AAEY,QAAA,gBAAgB,GAAG,gBAAgB,CAAC;AACpC,QAAA,sBAAsB,GAAG,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,0CAAwB;AACxB,0CAAwB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenstackhq/sdk",
3
- "version": "0.6.0-pre.2",
3
+ "version": "1.0.0-alpha.20",
4
4
  "description": "ZenStack plugin development SDK",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -12,14 +12,17 @@
12
12
  "license": "MIT",
13
13
  "dependencies": {
14
14
  "@prisma/generator-helper": "^4.7.1",
15
- "@zenstackhq/language": "0.6.0-pre.2"
15
+ "@zenstackhq/language": "1.0.0-alpha.20"
16
16
  },
17
17
  "devDependencies": {
18
+ "copyfiles": "^2.4.1",
19
+ "rimraf": "^3.0.2",
18
20
  "typescript": "^4.9.4"
19
21
  },
20
22
  "scripts": {
21
- "build-deps": "pnpm -C ../language build",
22
- "build": "pnpm build-deps && tsc && cp ./package.json ./README.md dist/",
23
+ "clean": "rimraf dist",
24
+ "lint": "eslint src --ext ts",
25
+ "build": "pnpm lint && pnpm clean && tsc && copyfiles ./package.json ./LICENSE ./README.md dist",
23
26
  "watch": "tsc --watch",
24
27
  "publish-dev": "pnpm build && pnpm publish --tag dev"
25
28
  }
package/types.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { DMMF } from '@prisma/generator-helper';
2
+ import { Model } from '@zenstackhq/language/ast';
3
+ /**
4
+ * Plugin configuration option value type
5
+ */
6
+ export type OptionValue = string | number | boolean;
7
+ /**
8
+ * Plugin configuration oiptions
9
+ */
10
+ export type PluginOptions = {
11
+ provider?: string;
12
+ } & Record<string, OptionValue | OptionValue[]>;
13
+ /**
14
+ * Plugin entry point function definition
15
+ */
16
+ export type PluginFunction = (model: Model, options: PluginOptions, dmmf?: DMMF.Document) => Promise<string[]> | string[] | Promise<void> | void;
17
+ /**
18
+ * Plugin error
19
+ */
20
+ export declare class PluginError extends Error {
21
+ constructor(message: string);
22
+ }
package/types.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PluginError = void 0;
4
+ /**
5
+ * Plugin error
6
+ */
7
+ class PluginError extends Error {
8
+ constructor(message) {
9
+ super(message);
10
+ }
11
+ }
12
+ exports.PluginError = PluginError;
13
+ //# sourceMappingURL=types.js.map
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAsBA;;GAEG;AACH,MAAa,WAAY,SAAQ,KAAK;IAClC,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;IACnB,CAAC;CACJ;AAJD,kCAIC"}
package/utils.d.ts CHANGED
@@ -3,3 +3,4 @@ export declare function resolved<T extends AstNode>(ref: Reference<T>): T;
3
3
  export declare function getLiteral<T extends string | number | boolean | any = any>(expr: Expression | undefined): T | undefined;
4
4
  export declare function getArray(expr: Expression | undefined): Expression[] | undefined;
5
5
  export declare function getLiteralArray<T extends string | number | boolean | any = any>(expr: Expression | undefined): (T | undefined)[] | undefined;
6
+ export default function indentString(string: string, count?: number): string;
package/utils.js CHANGED
@@ -9,6 +9,7 @@ function resolved(ref) {
9
9
  return ref.ref;
10
10
  }
11
11
  exports.resolved = resolved;
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
13
  function getLiteral(expr) {
13
14
  if (!(0, ast_1.isLiteralExpr)(expr)) {
14
15
  return undefined;
@@ -28,4 +29,9 @@ function getLiteralArray(expr) {
28
29
  return arr.map((item) => getLiteral(item));
29
30
  }
30
31
  exports.getLiteralArray = getLiteralArray;
32
+ function indentString(string, count = 4) {
33
+ const indent = ' ';
34
+ return string.replace(/^(?!\s*$)/gm, indent.repeat(count));
35
+ }
36
+ exports.default = indentString;
31
37
  //# sourceMappingURL=utils.js.map
package/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA,kDAMkC;AAElC,SAAgB,QAAQ,CAAoB,GAAiB;IACzD,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,2BAA2B,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;KAC9D;IACD,OAAO,GAAG,CAAC,GAAG,CAAC;AACnB,CAAC;AALD,4BAKC;AAED,SAAgB,UAAU,CACtB,IAA4B;IAE5B,IAAI,CAAC,IAAA,mBAAa,EAAC,IAAI,CAAC,EAAE;QACtB,OAAO,SAAS,CAAC;KACpB;IACD,OAAO,IAAI,CAAC,KAAU,CAAC;AAC3B,CAAC;AAPD,gCAOC;AAED,SAAgB,QAAQ,CACpB,IAA4B;IAE5B,OAAO,IAAA,iBAAW,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC;AAJD,4BAIC;AAED,SAAgB,eAAe,CAE7B,IAA4B;IAC1B,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,CAAC,GAAG,EAAE;QACN,OAAO,SAAS,CAAC;KACpB;IACD,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAI,IAAI,CAAC,CAAC,CAAC;AAClD,CAAC;AARD,0CAQC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA,kDAAsG;AAE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