prostgles-server 4.2.383 → 4.2.386

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.
@@ -1,4 +1,4 @@
1
1
  export declare const VALIDATE_SCHEMA_FUNCNAME = "validate_jsonb_schema";
2
- export declare const JSONB_DATA_TYPES: readonly ["boolean", "number", "integer", "string", "Date", "time", "timestamp", "any", ...("number[]" | "boolean[]" | "string[]" | "any[]" | "time[]" | "timestamp[]" | "integer[]" | "Date[]")[], "Lookup", "Lookup[]"];
2
+ export declare const JSONB_DATA_TYPES: readonly ["boolean", "number", "integer", "string", "Date", "time", "timestamp", "Blob", "any", "unknown", ...("number[]" | "boolean[]" | "string[]" | "any[]" | "time[]" | "timestamp[]" | "integer[]" | "Date[]" | "Blob[]" | "unknown[]")[], "Lookup", "Lookup[]"];
3
3
  export declare const validate_jsonb_schema_sql: string;
4
4
  //# sourceMappingURL=validateJSONBSchemaSQL.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validateJSONBSchemaSQL.d.ts","sourceRoot":"","sources":["../../lib/JSONBSchemaValidation/validateJSONBSchemaSQL.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,wBAAwB,0BAA0B,CAAC;AAChE,eAAO,MAAM,gBAAgB,2NAAiD,CAAC;AAE/E,eAAO,MAAM,yBAAyB,QAkerC,CAAC"}
1
+ {"version":3,"file":"validateJSONBSchemaSQL.d.ts","sourceRoot":"","sources":["../../lib/JSONBSchemaValidation/validateJSONBSchemaSQL.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,wBAAwB,0BAA0B,CAAC;AAChE,eAAO,MAAM,gBAAgB,uQAAiD,CAAC;AAE/E,eAAO,MAAM,yBAAyB,QAkerC,CAAC"}
@@ -26,14 +26,14 @@ export type ServerFunctionDefinitions<S = void, SUser extends SessionUser = Sess
26
26
  }) => MaybePromise<{
27
27
  [key: string]: ServerFunction<S, SUser>;
28
28
  }>;
29
- export declare const createDefineServerFunction: <S = void, SUser extends SessionUser = SessionUser>(isAllowed: (params: PublishParams<S, SUser>) => boolean | Promise<boolean>) => <TInput extends Record<string, JSONB.FieldType> | undefined = undefined>(args: {
29
+ export declare const createDefineServerFunction: <S = void, SUser extends SessionUser = SessionUser>(isAllowed: (params: PublishParams<S, SUser>) => boolean | Promise<boolean>, defaultOutput?: JSONB.FieldType) => <TInput extends Record<string, JSONB.FieldType> | undefined = undefined>(args: {
30
30
  input?: TInput | undefined;
31
31
  output?: JSONB.FieldType | undefined;
32
32
  description?: string | undefined;
33
33
  run: (args: JSONBObjectTypeIfDefined<TInput>, context: PublishParams<S, SUser>) => MaybePromise<unknown>;
34
34
  }) => ServerFunctionDefinition<never, never>;
35
35
  type TypeGuardResult<T, Fallback> = T extends (arg: any) => arg is infer R ? R : Fallback;
36
- export declare const createDefineServerFunctionWithContextGuard: <S, SUser extends SessionUser, TGuard extends (params: PublishParams<S, SUser>) => boolean>(isAllowed?: TGuard | undefined) => <TInput extends Record<string, JSONB.FieldType> | undefined = undefined>(args: {
36
+ export declare const createDefineServerFunctionWithContextGuard: <S, SUser extends SessionUser, TGuard extends (params: PublishParams<S, SUser>) => boolean>(isAllowed?: TGuard | undefined, defaultOutput?: JSONB.FieldType) => <TInput extends Record<string, JSONB.FieldType> | undefined = undefined>(args: {
37
37
  input?: TInput | undefined;
38
38
  output?: JSONB.FieldType | undefined;
39
39
  description?: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"defineServerFunction.d.ts","sourceRoot":"","sources":["../../lib/PublishParser/defineServerFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACrF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC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AO,CAAC,CAAC;CAChE,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;uFAa1B,aAAa,OAAO,CAAC;oDACsB,OAAO,GAAG,QAAQ,OAAO,CAAC;4CAC3B,CAAC;AAElD,MAAM,MAAM,cAAc,CACxB,CAAC,GAAG,IAAI,EACR,KAAK,SAAS,WAAW,GAAG,WAAW,IACrC,wBAAwB,CAAC,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG;IACtD,SAAS,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC5E,CAAC;AACF,MAAM,MAAM,yBAAyB,CACnC,CAAC,GAAG,IAAI,EACR,KAAK,SAAS,WAAW,GAAG,WAAW,IACrC,CAAC,MAAM,EAAE;IAAE,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAAC,EAAE,EAAE,EAAE,CAAA;CAAE,KAAK,YAAY,CAAC;IAC9D,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;CACzC,CAAC,CAAC;AAEH,eAAO,MAAM,0BAA0B,sGACW,OAAO,GAAG,QAAQ,OAAO,CAAC,kBAC1D,MAAM,SAAS;;;;uFASxB,aAAa,OAAO,CAAC;4CAO7B,CAAC;AAEF,KAAK,eAAe,CAAC,CAAC,EAAE,QAAQ,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;AAE1F,eAAO,MAAM,0CAA0C,qFAGD,OAAO,kDAG3C,MAAM,SAAS;;;;gHAS6C,aAAa,OAAO,CAAC;4CAOlG,CAAC"}
@@ -3,13 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createDefineServerFunctionWithContextGuard = exports.createDefineServerFunction = exports.defineServerFunction = void 0;
4
4
  const defineServerFunction = (args) => args;
5
5
  exports.defineServerFunction = defineServerFunction;
6
- const createDefineServerFunction = (isAllowed) => {
7
- return (args) => ({ ...args, isAllowed });
6
+ const createDefineServerFunction = (isAllowed, defaultOutput) => {
7
+ return (args) => ({
8
+ ...args,
9
+ output: args.output ?? defaultOutput,
10
+ isAllowed,
11
+ });
8
12
  };
9
13
  exports.createDefineServerFunction = createDefineServerFunction;
10
- const createDefineServerFunctionWithContextGuard = (isAllowed) => {
14
+ const createDefineServerFunctionWithContextGuard = (isAllowed, defaultOutput) => {
11
15
  return (args) => ({
12
16
  ...args,
17
+ output: args.output ?? defaultOutput,
13
18
  isAllowed,
14
19
  });
15
20
  };
@@ -1 +1 @@
1
- {"version":3,"file":"defineServerFunction.js","sourceRoot":"","sources":["../../lib/PublishParser/defineServerFunction.ts"],"names":[],"mappings":";;;AAcO,MAAM,oBAAoB,GAAG,CAMlC,IASD,EAAE,EAAE,CAAC,IAA2C,CAAC;AAfrC,QAAA,oBAAoB,wBAeiB;AAe3C,MAAM,0BAA0B,GAAG,CACxC,SAA0E,EAC1E,EAAE;IACF,OAAO,CAAyE,IAQ/E,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,CAAwC,CAAC;AACxE,CAAC,CAAC;AAZW,QAAA,0BAA0B,8BAYrC;AAIK,MAAM,0CAA0C,GAAG,CAKxD,SAAkB,EAClB,EAAE;IAIF,OAAO,CAAyE,IAK/E,EAAE,EAAE,CACH,CAAC;QACC,GAAG,IAAI;QACP,SAAS;KACV,CAAwC,CAAC;AAC9C,CAAC,CAAC;AApBW,QAAA,0CAA0C,8CAoBrD"}
1
+ {"version":3,"file":"defineServerFunction.js","sourceRoot":"","sources":["../../lib/PublishParser/defineServerFunction.ts"],"names":[],"mappings":";;;AAcO,MAAM,oBAAoB,GAAG,CAMlC,IASD,EAAE,EAAE,CAAC,IAA2C,CAAC;AAfrC,QAAA,oBAAoB,wBAeiB;AAe3C,MAAM,0BAA0B,GAAG,CACxC,SAA0E,EAC1E,aAA+B,EAC/B,EAAE;IACF,OAAO,CAAyE,IAQ/E,EAAE,EAAE,CACH,CAAC;QACC,GAAG,IAAI;QACP,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,aAAa;QACpC,SAAS;KACV,CAAwC,CAAC;AAC9C,CAAC,CAAC;AAlBW,QAAA,0BAA0B,8BAkBrC;AAIK,MAAM,0CAA0C,GAAG,CAKxD,SAAkB,EAClB,aAA+B,EAC/B,EAAE;IAIF,OAAO,CAAyE,IAK/E,EAAE,EAAE,CACH,CAAC;QACC,GAAG,IAAI;QACP,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,aAAa;QACpC,SAAS;KACV,CAAwC,CAAC;AAC9C,CAAC,CAAC;AAtBW,QAAA,0CAA0C,8CAsBrD"}
@@ -43,7 +43,8 @@ export type ServerFunctionDefinitions<
43
43
  }>;
44
44
 
45
45
  export const createDefineServerFunction = <S = void, SUser extends SessionUser = SessionUser>(
46
- isAllowed: (params: PublishParams<S, SUser>) => boolean | Promise<boolean>
46
+ isAllowed: (params: PublishParams<S, SUser>) => boolean | Promise<boolean>,
47
+ defaultOutput?: JSONB.FieldType
47
48
  ) => {
48
49
  return <TInput extends Record<string, JSONB.FieldType> | undefined = undefined>(args: {
49
50
  input?: TInput;
@@ -53,7 +54,12 @@ export const createDefineServerFunction = <S = void, SUser extends SessionUser =
53
54
  args: JSONBObjectTypeIfDefined<TInput>,
54
55
  context: PublishParams<S, SUser>
55
56
  ) => MaybePromise<unknown>;
56
- }) => ({ ...args, isAllowed }) as unknown as ServerFunctionDefinition;
57
+ }) =>
58
+ ({
59
+ ...args,
60
+ output: args.output ?? defaultOutput,
61
+ isAllowed,
62
+ }) as unknown as ServerFunctionDefinition;
57
63
  };
58
64
 
59
65
  type TypeGuardResult<T, Fallback> = T extends (arg: any) => arg is infer R ? R : Fallback;
@@ -63,7 +69,8 @@ export const createDefineServerFunctionWithContextGuard = <
63
69
  SUser extends SessionUser,
64
70
  TGuard extends (params: PublishParams<S, SUser>) => boolean,
65
71
  >(
66
- isAllowed?: TGuard
72
+ isAllowed?: TGuard,
73
+ defaultOutput?: JSONB.FieldType
67
74
  ) => {
68
75
  type BaseContext = PublishParams<S, SUser>;
69
76
  type GuardedContext = TypeGuardResult<TGuard, BaseContext>;
@@ -76,6 +83,7 @@ export const createDefineServerFunctionWithContextGuard = <
76
83
  }) =>
77
84
  ({
78
85
  ...args,
86
+ output: args.output ?? defaultOutput,
79
87
  isAllowed,
80
88
  }) as unknown as ServerFunctionDefinition;
81
89
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prostgles-server",
3
- "version": "4.2.383",
3
+ "version": "4.2.386",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,7 +17,7 @@
17
17
  "test-quick": "cd tests/ && ./test.sh -quick",
18
18
  "test": "npm run test:lib && npm run test-only",
19
19
  "generate-docs": "rm -f ./docs/*.md && cd docs/utils && npm start",
20
- "pushpublish": "npm run generate-docs && npm version patch --git-tag-version false && git push && npm publish",
20
+ "pushpublish": "npm run generate-docs && npm version patch --git-tag-version false && git push && npm publish --no-audit",
21
21
  "circular-deps": "tsc && npx madge --circular ."
22
22
  },
23
23
  "repository": {
@@ -57,7 +57,7 @@
57
57
  "pg": "^8.15.6",
58
58
  "pg-cursor": "^2.14.6",
59
59
  "pg-promise": "^11.13.0",
60
- "prostgles-types": "^4.0.201"
60
+ "prostgles-types": "^4.0.202"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@eslint/js": "^9.22.0",