prostgles-server 4.2.591 → 4.2.592
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/DBSchemaBuilder/getServerFunctionReturnTypes.fixture.d.ts +38 -0
- package/dist/DBSchemaBuilder/getServerFunctionReturnTypes.fixture.d.ts.map +1 -1
- package/dist/DBSchemaBuilder/getServerFunctionReturnTypes.fixture.js +22 -18
- package/dist/DBSchemaBuilder/getServerFunctionReturnTypes.fixture.js.map +1 -1
- package/dist/PublishParser/defineServerFunction.d.ts +1 -1
- package/dist/PublishParser/defineServerFunction.d.ts.map +1 -1
- package/dist/PublishParser/defineServerFunction.js.map +1 -1
- package/lib/DBSchemaBuilder/getServerFunctionReturnTypes.fixture.ts +23 -19
- package/lib/PublishParser/defineServerFunction.ts +4 -1
- package/package.json +1 -1
|
@@ -1,2 +1,40 @@
|
|
|
1
|
+
type RecursiveResult = {
|
|
2
|
+
value: string;
|
|
3
|
+
next?: RecursiveResult;
|
|
4
|
+
};
|
|
5
|
+
type FixtureSchema = {
|
|
6
|
+
orders: {
|
|
7
|
+
columns: {
|
|
8
|
+
id: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare const stateServerFunctions: {
|
|
13
|
+
readonly public: {
|
|
14
|
+
readonly userFilter: {
|
|
15
|
+
readonly type: "public";
|
|
16
|
+
};
|
|
17
|
+
readonly functions: {
|
|
18
|
+
readonly recursiveResult: {
|
|
19
|
+
input?: Record<string, import("prostgles-types").JSONB.FieldType> | undefined;
|
|
20
|
+
description?: string;
|
|
21
|
+
run: (args: import("prostgles-types").JSONB.GetObjectType<Record<string, import("prostgles-types").JSONB.FieldType>>, context: import("..").RestrictedFunctionContext<FixtureSchema, import("..").SessionUser>) => import("prostgles-types").MaybePromise<RecursiveResult>;
|
|
22
|
+
} & {
|
|
23
|
+
unrestrictedDbAccess?: undefined;
|
|
24
|
+
} & import("..").ServerFunctionContextMarker<FixtureSchema, import("..").SessionUser>;
|
|
25
|
+
readonly scalarResult: {
|
|
26
|
+
input?: {
|
|
27
|
+
value: "number";
|
|
28
|
+
} | undefined;
|
|
29
|
+
description?: string;
|
|
30
|
+
run: (args: import("prostgles-types").JSONB.GetObjectType<{
|
|
31
|
+
value: "number";
|
|
32
|
+
}>, context: import("..").RestrictedFunctionContext<FixtureSchema, import("..").SessionUser>) => import("prostgles-types").MaybePromise<number>;
|
|
33
|
+
} & {
|
|
34
|
+
unrestrictedDbAccess?: undefined;
|
|
35
|
+
} & import("..").ServerFunctionContextMarker<FixtureSchema, import("..").SessionUser>;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
1
39
|
export {};
|
|
2
40
|
//# sourceMappingURL=getServerFunctionReturnTypes.fixture.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getServerFunctionReturnTypes.fixture.d.ts","sourceRoot":"","sources":["../../lib/DBSchemaBuilder/getServerFunctionReturnTypes.fixture.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"getServerFunctionReturnTypes.fixture.d.ts","sourceRoot":"","sources":["../../lib/DBSchemaBuilder/getServerFunctionReturnTypes.fixture.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,eAAe,CAAC;CACxB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE;QACN,OAAO,EAAE;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC;KACzB,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;CAmB4B,CAAC"}
|
|
@@ -33,27 +33,31 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.stateServerFunctions = void 0;
|
|
36
37
|
const __1 = __importStar(require(".."));
|
|
38
|
+
exports.stateServerFunctions = {
|
|
39
|
+
public: {
|
|
40
|
+
userFilter: { type: "public" },
|
|
41
|
+
functions: {
|
|
42
|
+
recursiveResult: (0, __1.defineFunction)({
|
|
43
|
+
run: () => ({ value: "ok" }),
|
|
44
|
+
}),
|
|
45
|
+
scalarResult: (0, __1.defineFunction)({
|
|
46
|
+
input: { value: "number" },
|
|
47
|
+
run: ({ value }, { dbo }) => {
|
|
48
|
+
value;
|
|
49
|
+
void dbo.orders.find();
|
|
50
|
+
// @ts-expect-error The schema must reach a function defined in another object.
|
|
51
|
+
void dbo.missingTable;
|
|
52
|
+
return value;
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
37
58
|
void (0, __1.default)({
|
|
38
59
|
dbConnection: "",
|
|
39
60
|
onReady: () => { },
|
|
40
|
-
functions:
|
|
41
|
-
public: {
|
|
42
|
-
userFilter: { type: "public" },
|
|
43
|
-
functions: {
|
|
44
|
-
recursiveResult: (0, __1.defineFunction)({
|
|
45
|
-
run: () => ({ value: "ok" }),
|
|
46
|
-
}),
|
|
47
|
-
scalarResult: (0, __1.defineFunction)({
|
|
48
|
-
run: (_args, { dbo }) => {
|
|
49
|
-
void dbo.orders.find();
|
|
50
|
-
// @ts-expect-error The surrounding prostgles schema must reach defineFunction.
|
|
51
|
-
void dbo.missingTable;
|
|
52
|
-
return 42;
|
|
53
|
-
},
|
|
54
|
-
}),
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
},
|
|
61
|
+
functions: exports.stateServerFunctions,
|
|
58
62
|
});
|
|
59
63
|
//# sourceMappingURL=getServerFunctionReturnTypes.fixture.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getServerFunctionReturnTypes.fixture.js","sourceRoot":"","sources":["../../lib/DBSchemaBuilder/getServerFunctionReturnTypes.fixture.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getServerFunctionReturnTypes.fixture.js","sourceRoot":"","sources":["../../lib/DBSchemaBuilder/getServerFunctionReturnTypes.fixture.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAA+E;AAalE,QAAA,oBAAoB,GAAG;IAClC,MAAM,EAAE;QACN,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC9B,SAAS,EAAE;YACT,eAAe,EAAE,IAAA,kBAAc,EAAC;gBAC9B,GAAG,EAAE,GAAoB,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;aAC9C,CAAC;YACF,YAAY,EAAE,IAAA,kBAAc,EAAC;gBAC3B,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE;gBAC1B,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;oBAC1B,KAAsB,CAAC;oBACvB,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;oBACvB,+EAA+E;oBAC/E,KAAK,GAAG,CAAC,YAAY,CAAC;oBACtB,OAAO,KAAK,CAAC;gBACf,CAAC;aACF,CAAC;SACH;KACF;CAC0D,CAAC;AAE9D,KAAK,IAAA,WAAS,EAAgB;IAC5B,YAAY,EAAE,EAAE;IAChB,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;IACjB,SAAS,EAAE,4BAAoB;CAChC,CAAC,CAAC"}
|
|
@@ -21,7 +21,7 @@ export type ServerFunctionDefinition = {
|
|
|
21
21
|
run: (...args: any[]) => MaybePromise<unknown>;
|
|
22
22
|
};
|
|
23
23
|
declare const serverFunctionContext: unique symbol;
|
|
24
|
-
type ServerFunctionContextMarker<S, SUser extends SessionUser> = {
|
|
24
|
+
export type ServerFunctionContextMarker<S, SUser extends SessionUser> = {
|
|
25
25
|
[serverFunctionContext]?: [S, SUser];
|
|
26
26
|
};
|
|
27
27
|
type DefineFunctionArgs<TInput extends Record<string, JSONB.FieldType> | undefined, Context, Return> = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineServerFunction.d.ts","sourceRoot":"","sources":["../../lib/PublishParser/defineServerFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,UAAU,EACV,KAAK,EACL,wBAAwB,EACxB,YAAY,EACZ,UAAU,EACX,MAAM,iBAAiB,CAAC;AACzB,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;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D,KAAK,mBAAmB,CAAC,CAAC,EAAE,KAAK,SAAS,WAAW,IAAI,IAAI,CAC3D,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,EACvB,QAAQ,GAAG,WAAW,GAAG,YAAY,CACtC,GAAG;IACF,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IACtB,IAAI,EAAE,CAAC,SAAS,QAAQ,GACtB,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,SAAS,SAAS,GACrC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,GAC/B,KAAK,CAAC,MAAM,CAAC,GACf,KAAK,CAAC,MAAM,CAAC,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,yBAAyB,CACnC,CAAC,GAAG,IAAI,EACR,KAAK,SAAS,WAAW,GAAG,WAAW,IACrC,mBAAmB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAElC,MAAM,MAAM,2BAA2B,CACrC,CAAC,GAAG,IAAI,EACR,KAAK,SAAS,WAAW,GAAG,WAAW,IACrC,mBAAmB,CAAC,CAAC,EAA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AChB,CAAC,SAAS;IAAE,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,OAAO,SAAS,SAAS,CAAA;KAAE,CAAA;CAAE,GAC/D,OAAO,GACP,SAAS,GACX,SAAS,CAAC;AAEd,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,QAAQ,GAAG,CAAC,GAAG,IAAI,CAAC;AAEtD,MAAM,MAAM,yBAAyB,CACnC,CAAC,GAAG,IAAI,EACR,KAAK,SAAS,WAAW,GAAG,WAAW,IACrC,MAAM,CACR,MAAM,EACN;IACE,UAAU,EAAE,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,SAAS,EAAE,MAAM,CACf,MAAM,EACN,wBAAwB,GAAG,2BAA2B,CAAC,CAAC,EAAE,KAAK,CAAC,CACjE,CAAC;CACH,CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineServerFunction.js","sourceRoot":"","sources":["../../lib/PublishParser/defineServerFunction.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"defineServerFunction.js","sourceRoot":"","sources":["../../lib/PublishParser/defineServerFunction.ts"],"names":[],"mappings":";;AAwFA,wCAEC;AAFD,SAAgB,cAAc,CAAC,IAAa;IAC1C,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import prostgles, { defineFunction } from "..";
|
|
1
|
+
import prostgles, { defineFunction, type ServerFunctionDefinitions } from "..";
|
|
2
2
|
|
|
3
3
|
type RecursiveResult = {
|
|
4
4
|
value: string;
|
|
@@ -11,25 +11,29 @@ type FixtureSchema = {
|
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
export const stateServerFunctions = {
|
|
15
|
+
public: {
|
|
16
|
+
userFilter: { type: "public" },
|
|
17
|
+
functions: {
|
|
18
|
+
recursiveResult: defineFunction({
|
|
19
|
+
run: (): RecursiveResult => ({ value: "ok" }),
|
|
20
|
+
}),
|
|
21
|
+
scalarResult: defineFunction({
|
|
22
|
+
input: { value: "number" },
|
|
23
|
+
run: ({ value }, { dbo }) => {
|
|
24
|
+
value satisfies number;
|
|
25
|
+
void dbo.orders.find();
|
|
26
|
+
// @ts-expect-error The schema must reach a function defined in another object.
|
|
27
|
+
void dbo.missingTable;
|
|
28
|
+
return value;
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
} as const satisfies ServerFunctionDefinitions<FixtureSchema>;
|
|
34
|
+
|
|
14
35
|
void prostgles<FixtureSchema>({
|
|
15
36
|
dbConnection: "",
|
|
16
37
|
onReady: () => {},
|
|
17
|
-
functions:
|
|
18
|
-
public: {
|
|
19
|
-
userFilter: { type: "public" },
|
|
20
|
-
functions: {
|
|
21
|
-
recursiveResult: defineFunction({
|
|
22
|
-
run: (): RecursiveResult => ({ value: "ok" }),
|
|
23
|
-
}),
|
|
24
|
-
scalarResult: defineFunction({
|
|
25
|
-
run: (_args, { dbo }) => {
|
|
26
|
-
void dbo.orders.find();
|
|
27
|
-
// @ts-expect-error The surrounding prostgles schema must reach defineFunction.
|
|
28
|
-
void dbo.missingTable;
|
|
29
|
-
return 42;
|
|
30
|
-
},
|
|
31
|
-
}),
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
38
|
+
functions: stateServerFunctions,
|
|
35
39
|
});
|
|
@@ -48,7 +48,10 @@ export type ServerFunctionDefinition = {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
declare const serverFunctionContext: unique symbol;
|
|
51
|
-
type ServerFunctionContextMarker<
|
|
51
|
+
export type ServerFunctionContextMarker<
|
|
52
|
+
S,
|
|
53
|
+
SUser extends SessionUser,
|
|
54
|
+
> = {
|
|
52
55
|
[serverFunctionContext]?: [S, SUser];
|
|
53
56
|
};
|
|
54
57
|
|