prostgles-server 4.2.179 → 4.2.180
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/.vscode/settings.json +10 -1
- package/dist/DboBuilder/TableHandler/DataValidator.d.ts +1 -1
- package/dist/DboBuilder/TableHandler/DataValidator.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/DataValidator.js +4 -4
- package/dist/DboBuilder/TableHandler/DataValidator.js.map +1 -1
- package/dist/DboBuilder/TableHandler/TableHandler.d.ts +1 -1
- package/dist/DboBuilder/TableHandler/TableHandler.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/insert.js +3 -3
- package/dist/DboBuilder/TableHandler/insert.js.map +1 -1
- package/dist/DboBuilder/TableHandler/update.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/update.js +45 -19
- package/dist/DboBuilder/TableHandler/update.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/ViewHandler.d.ts +1 -1
- package/dist/DboBuilder/ViewHandler/ViewHandler.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/ViewHandler.js +2 -2
- package/dist/DboBuilder/ViewHandler/ViewHandler.js.map +1 -1
- package/dist/DboBuilder/parseUpdateRules.js +1 -1
- package/dist/DboBuilder/parseUpdateRules.js.map +1 -1
- package/dist/Prostgles.d.ts +2 -2
- package/dist/Prostgles.d.ts.map +1 -1
- package/dist/Prostgles.js +118 -54
- package/dist/Prostgles.js.map +1 -1
- package/dist/ProstglesTypes.d.ts +77 -23
- package/dist/ProstglesTypes.d.ts.map +1 -1
- package/dist/ProstglesTypes.js.map +1 -1
- package/dist/SyncReplication.js +2 -2
- package/dist/SyncReplication.js.map +1 -1
- package/dist/initProstgles.d.ts +9 -2
- package/dist/initProstgles.d.ts.map +1 -1
- package/dist/initProstgles.js +65 -57
- package/dist/initProstgles.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js.map +1 -1
- package/documentation/CLIENT.md +542 -0
- package/documentation/SERVER.md +104 -0
- package/documentation/utils/clientTypes.ts +8436 -0
- package/documentation/utils/dist/clientTypes.d.ts +7705 -0
- package/documentation/utils/dist/clientTypes.d.ts.map +1 -0
- package/documentation/utils/dist/clientTypes.js +8438 -0
- package/documentation/utils/dist/definitions.d.ts +7705 -0
- package/documentation/utils/dist/definitions.d.ts.map +1 -0
- package/documentation/utils/dist/definitions.js +8438 -0
- package/documentation/utils/dist/generateClientDocs.d.ts +3 -0
- package/documentation/utils/dist/generateClientDocs.d.ts.map +1 -0
- package/documentation/utils/dist/generateClientDocs.js +115 -0
- package/documentation/utils/dist/generateDocs.d.ts +2 -0
- package/documentation/utils/dist/generateDocs.d.ts.map +1 -0
- package/documentation/utils/dist/generateDocs.js +6 -0
- package/documentation/utils/dist/generateMarkdown.d.ts +2 -0
- package/documentation/utils/dist/generateMarkdown.d.ts.map +1 -0
- package/documentation/utils/dist/generateMarkdown.js +68 -0
- package/documentation/utils/dist/generateServerDocs.d.ts +2 -0
- package/documentation/utils/dist/generateServerDocs.d.ts.map +1 -0
- package/documentation/utils/dist/generateServerDocs.js +80 -0
- package/documentation/utils/dist/getResolvedTypes.d.ts +15 -0
- package/documentation/utils/dist/getResolvedTypes.d.ts.map +1 -0
- package/documentation/utils/dist/getResolvedTypes.js +29 -0
- package/documentation/utils/dist/getSerializableType.d.ts +69 -0
- package/documentation/utils/dist/getSerializableType.d.ts.map +1 -0
- package/documentation/utils/dist/getSerializableType.js +273 -0
- package/documentation/utils/dist/getSymbolComments.d.ts +11 -0
- package/documentation/utils/dist/getSymbolComments.d.ts.map +1 -0
- package/documentation/utils/dist/getSymbolComments.js +60 -0
- package/documentation/utils/dist/loadTsFile.d.ts +7 -0
- package/documentation/utils/dist/loadTsFile.d.ts.map +1 -0
- package/documentation/utils/dist/loadTsFile.js +33 -0
- package/documentation/utils/dist/moduleResolver.d.ts +9 -0
- package/documentation/utils/dist/moduleResolver.d.ts.map +1 -0
- package/documentation/utils/dist/moduleResolver.js +27 -0
- package/documentation/utils/dist/serverTypes.d.ts +307 -0
- package/documentation/utils/dist/serverTypes.d.ts.map +1 -0
- package/documentation/utils/dist/serverTypes.js +347 -0
- package/documentation/utils/generateClientDocs.ts +142 -0
- package/documentation/utils/generateDocs.ts +4 -0
- package/documentation/utils/generateServerDocs.ts +82 -0
- package/documentation/utils/getResolvedTypes.ts +45 -0
- package/documentation/utils/getSerializableType.ts +479 -0
- package/documentation/utils/loadTsFile.ts +45 -0
- package/documentation/utils/moduleResolver.ts +31 -0
- package/documentation/utils/node_modules/.package-lock.json +67 -0
- package/documentation/utils/node_modules/@types/node/LICENSE +21 -0
- package/documentation/utils/node_modules/@types/node/README.md +15 -0
- package/documentation/utils/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/documentation/utils/node_modules/@types/node/assert.d.ts +1040 -0
- package/documentation/utils/node_modules/@types/node/async_hooks.d.ts +541 -0
- package/documentation/utils/node_modules/@types/node/buffer.buffer.d.ts +385 -0
- package/documentation/utils/node_modules/@types/node/buffer.d.ts +1934 -0
- package/documentation/utils/node_modules/@types/node/child_process.d.ts +1548 -0
- package/documentation/utils/node_modules/@types/node/cluster.d.ts +578 -0
- package/documentation/utils/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
- package/documentation/utils/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/documentation/utils/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
- package/documentation/utils/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/documentation/utils/node_modules/@types/node/console.d.ts +452 -0
- package/documentation/utils/node_modules/@types/node/constants.d.ts +19 -0
- package/documentation/utils/node_modules/@types/node/crypto.d.ts +4519 -0
- package/documentation/utils/node_modules/@types/node/dgram.d.ts +596 -0
- package/documentation/utils/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
- package/documentation/utils/node_modules/@types/node/dns/promises.d.ts +477 -0
- package/documentation/utils/node_modules/@types/node/dns.d.ts +864 -0
- package/documentation/utils/node_modules/@types/node/dom-events.d.ts +124 -0
- package/documentation/utils/node_modules/@types/node/domain.d.ts +170 -0
- package/documentation/utils/node_modules/@types/node/events.d.ts +931 -0
- package/documentation/utils/node_modules/@types/node/fs/promises.d.ts +1245 -0
- package/documentation/utils/node_modules/@types/node/fs.d.ts +4317 -0
- package/documentation/utils/node_modules/@types/node/globals.d.ts +468 -0
- package/documentation/utils/node_modules/@types/node/globals.typedarray.d.ts +21 -0
- package/documentation/utils/node_modules/@types/node/http.d.ts +1944 -0
- package/documentation/utils/node_modules/@types/node/http2.d.ts +2555 -0
- package/documentation/utils/node_modules/@types/node/https.d.ts +544 -0
- package/documentation/utils/node_modules/@types/node/index.d.ts +91 -0
- package/documentation/utils/node_modules/@types/node/inspector.d.ts +3696 -0
- package/documentation/utils/node_modules/@types/node/module.d.ts +315 -0
- package/documentation/utils/node_modules/@types/node/net.d.ts +1005 -0
- package/documentation/utils/node_modules/@types/node/os.d.ts +495 -0
- package/documentation/utils/node_modules/@types/node/package.json +220 -0
- package/documentation/utils/node_modules/@types/node/path.d.ts +200 -0
- package/documentation/utils/node_modules/@types/node/perf_hooks.d.ts +934 -0
- package/documentation/utils/node_modules/@types/node/process.d.ts +1879 -0
- package/documentation/utils/node_modules/@types/node/punycode.d.ts +117 -0
- package/documentation/utils/node_modules/@types/node/querystring.d.ts +153 -0
- package/documentation/utils/node_modules/@types/node/readline/promises.d.ts +162 -0
- package/documentation/utils/node_modules/@types/node/readline.d.ts +589 -0
- package/documentation/utils/node_modules/@types/node/repl.d.ts +430 -0
- package/documentation/utils/node_modules/@types/node/sea.d.ts +153 -0
- package/documentation/utils/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/documentation/utils/node_modules/@types/node/stream/promises.d.ts +90 -0
- package/documentation/utils/node_modules/@types/node/stream/web.d.ts +524 -0
- package/documentation/utils/node_modules/@types/node/stream.d.ts +1726 -0
- package/documentation/utils/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/documentation/utils/node_modules/@types/node/test.d.ts +1938 -0
- package/documentation/utils/node_modules/@types/node/timers/promises.d.ts +97 -0
- package/documentation/utils/node_modules/@types/node/timers.d.ts +240 -0
- package/documentation/utils/node_modules/@types/node/tls.d.ts +1217 -0
- package/documentation/utils/node_modules/@types/node/trace_events.d.ts +197 -0
- package/documentation/utils/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +385 -0
- package/documentation/utils/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +19 -0
- package/documentation/utils/node_modules/@types/node/ts5.6/index.d.ts +91 -0
- package/documentation/utils/node_modules/@types/node/tty.d.ts +208 -0
- package/documentation/utils/node_modules/@types/node/url.d.ts +955 -0
- package/documentation/utils/node_modules/@types/node/util.d.ts +2306 -0
- package/documentation/utils/node_modules/@types/node/v8.d.ts +808 -0
- package/documentation/utils/node_modules/@types/node/vm.d.ts +922 -0
- package/documentation/utils/node_modules/@types/node/wasi.d.ts +181 -0
- package/documentation/utils/node_modules/@types/node/worker_threads.d.ts +694 -0
- package/documentation/utils/node_modules/@types/node/zlib.d.ts +539 -0
- package/documentation/utils/node_modules/undici-types/LICENSE +21 -0
- package/documentation/utils/node_modules/undici-types/README.md +6 -0
- package/documentation/utils/node_modules/undici-types/agent.d.ts +31 -0
- package/documentation/utils/node_modules/undici-types/api.d.ts +43 -0
- package/documentation/utils/node_modules/undici-types/balanced-pool.d.ts +29 -0
- package/documentation/utils/node_modules/undici-types/cache.d.ts +36 -0
- package/documentation/utils/node_modules/undici-types/client.d.ts +108 -0
- package/documentation/utils/node_modules/undici-types/connector.d.ts +34 -0
- package/documentation/utils/node_modules/undici-types/content-type.d.ts +21 -0
- package/documentation/utils/node_modules/undici-types/cookies.d.ts +28 -0
- package/documentation/utils/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
- package/documentation/utils/node_modules/undici-types/dispatcher.d.ts +255 -0
- package/documentation/utils/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
- package/documentation/utils/node_modules/undici-types/errors.d.ts +149 -0
- package/documentation/utils/node_modules/undici-types/eventsource.d.ts +63 -0
- package/documentation/utils/node_modules/undici-types/fetch.d.ts +209 -0
- package/documentation/utils/node_modules/undici-types/file.d.ts +39 -0
- package/documentation/utils/node_modules/undici-types/filereader.d.ts +54 -0
- package/documentation/utils/node_modules/undici-types/formdata.d.ts +108 -0
- package/documentation/utils/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/documentation/utils/node_modules/undici-types/global-origin.d.ts +7 -0
- package/documentation/utils/node_modules/undici-types/handlers.d.ts +15 -0
- package/documentation/utils/node_modules/undici-types/header.d.ts +4 -0
- package/documentation/utils/node_modules/undici-types/index.d.ts +71 -0
- package/documentation/utils/node_modules/undici-types/interceptors.d.ts +15 -0
- package/documentation/utils/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/documentation/utils/node_modules/undici-types/mock-client.d.ts +25 -0
- package/documentation/utils/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/documentation/utils/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/documentation/utils/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/documentation/utils/node_modules/undici-types/package.json +55 -0
- package/documentation/utils/node_modules/undici-types/patch.d.ts +71 -0
- package/documentation/utils/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/documentation/utils/node_modules/undici-types/pool.d.ts +39 -0
- package/documentation/utils/node_modules/undici-types/proxy-agent.d.ts +28 -0
- package/documentation/utils/node_modules/undici-types/readable.d.ts +60 -0
- package/documentation/utils/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/documentation/utils/node_modules/undici-types/retry-handler.d.ts +116 -0
- package/documentation/utils/node_modules/undici-types/util.d.ts +18 -0
- package/documentation/utils/node_modules/undici-types/webidl.d.ts +222 -0
- package/documentation/utils/node_modules/undici-types/websocket.d.ts +152 -0
- package/documentation/utils/package-lock.json +75 -0
- package/documentation/utils/package.json +14 -0
- package/documentation/utils/serverTypes.ts +345 -0
- package/documentation/utils/tsconfig.json +28 -0
- package/examples/full-example-typescript/DBoGenerated.d.ts +2 -2
- package/examples/full-example-typescript/DBoGenerated.ts +2 -2
- package/examples/full-example-typescript/index.ts +39 -45
- package/examples/full-example-vanilla/index.js +51 -53
- package/examples/server/typescript/index.ts +24 -30
- package/lib/DboBuilder/TableHandler/DataValidator.ts +5 -5
- package/lib/DboBuilder/TableHandler/TableHandler.ts +1 -1
- package/lib/DboBuilder/TableHandler/insert.ts +3 -3
- package/lib/DboBuilder/TableHandler/update.ts +106 -48
- package/lib/DboBuilder/ViewHandler/ViewHandler.ts +2 -2
- package/lib/DboBuilder/parseUpdateRules.ts +1 -1
- package/lib/Prostgles.ts +209 -143
- package/lib/ProstglesTypes.ts +130 -51
- package/lib/SyncReplication.ts +2 -2
- package/lib/initProstgles.ts +145 -111
- package/lib/utils.ts +4 -5
- package/package.json +3 -2
- package/examples/server/typescript/index.d.ts +0 -2
- package/examples/server/typescript/index.d.ts.map +0 -1
- package/examples/server/typescript/index.js +0 -54
- package/examples/server/typescript/index.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateClientDocs.d.ts","sourceRoot":"","sources":["../generateClientDocs.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,kBAAkB,YAkD9B,CAAC;AAOF,eAAO,MAAM,WAAW,aAAc,MAAM,SA4B3C,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateMDX = exports.generateClientDocs = void 0;
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const prostgles_types_1 = require("prostgles-types");
|
|
7
|
+
const getResolvedTypes_1 = require("./getResolvedTypes");
|
|
8
|
+
const prostgles_types_2 = require("prostgles-types");
|
|
9
|
+
const clientTypes_1 = require("./clientTypes");
|
|
10
|
+
const testFolderPath = `${__dirname}/../../../tests/`;
|
|
11
|
+
const docsFolder = `${__dirname}/../../`;
|
|
12
|
+
const generateClientDocs = () => {
|
|
13
|
+
const clientFilePath = path.resolve(`${testFolderPath}/client/node_modules/prostgles-client/dist/prostgles.d.ts`);
|
|
14
|
+
const excludedTypes = [
|
|
15
|
+
"FullFilter",
|
|
16
|
+
"FullFilter<T, S> | undefined",
|
|
17
|
+
"FieldFilter | undefined",
|
|
18
|
+
"SyncOptions",
|
|
19
|
+
"SyncOneOptions",
|
|
20
|
+
"PG_COLUMN_UDT_DATA_TYPE",
|
|
21
|
+
];
|
|
22
|
+
const { resolvedTypes, visitedMaps } = (0, getResolvedTypes_1.getResolvedTypes)({
|
|
23
|
+
filePath: clientFilePath,
|
|
24
|
+
filter: {
|
|
25
|
+
nodeNames: [
|
|
26
|
+
// "ViewHandlerClient",
|
|
27
|
+
"TableHandlerClient",
|
|
28
|
+
],
|
|
29
|
+
excludedTypes,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
const jsonTypes = JSON.stringify([
|
|
33
|
+
...resolvedTypes,
|
|
34
|
+
...visitedMaps
|
|
35
|
+
.flatMap((m) => Array.from(m.values()).map((v) => { var _a; return excludedTypes.includes((_a = v.resolvedType.alias) !== null && _a !== void 0 ? _a : "") ? v.resolvedType : undefined; }))
|
|
36
|
+
.filter(prostgles_types_1.isDefined),
|
|
37
|
+
], null, 2);
|
|
38
|
+
fs.writeFileSync(`${__dirname}/../clientTypes.ts`, [
|
|
39
|
+
`import type { TS_Type } from "./getSerializableType";`,
|
|
40
|
+
`export const definitions = ${jsonTypes} as const satisfies TS_Type[];`,
|
|
41
|
+
].join("\n"), {
|
|
42
|
+
encoding: "utf-8",
|
|
43
|
+
});
|
|
44
|
+
const docPath = `${docsFolder}CLIENT.md`;
|
|
45
|
+
(0, exports.generateMDX)(docPath);
|
|
46
|
+
};
|
|
47
|
+
exports.generateClientDocs = generateClientDocs;
|
|
48
|
+
const getAliasWithoutGenerics = (type) => {
|
|
49
|
+
if (type.type === "union")
|
|
50
|
+
return type.types.map(getAliasWithoutGenerics).join(" | ");
|
|
51
|
+
return type.aliasSymbolescapedName || type.alias;
|
|
52
|
+
};
|
|
53
|
+
const generateMDX = (filePath) => {
|
|
54
|
+
const tableHandler = clientTypes_1.definitions[0];
|
|
55
|
+
const mdxContent = (0, prostgles_types_2.getObjectEntries)(tableHandler.properties).map(([methodName, _methodInfo]) => {
|
|
56
|
+
var _a;
|
|
57
|
+
const methodInfo = (_methodInfo.type === "function" ?
|
|
58
|
+
_methodInfo
|
|
59
|
+
// : _methodInfo.type === "union" ? _methodInfo.types.find((t) => t.type === "function")
|
|
60
|
+
: undefined);
|
|
61
|
+
if (!methodInfo)
|
|
62
|
+
return "";
|
|
63
|
+
return [
|
|
64
|
+
`## ${methodName}()`,
|
|
65
|
+
(_a = methodInfo.comments) !== null && _a !== void 0 ? _a : "",
|
|
66
|
+
`\`\`\`typescript
|
|
67
|
+
${methodName}: (${methodInfo.arguments
|
|
68
|
+
.map((arg) => `${arg.name}${arg.optional ? "?" : ""}: ${getAliasWithoutGenerics(arg)}`)
|
|
69
|
+
.join(", ")}): ${methodInfo.returnType.aliasSymbolescapedName || methodInfo.returnType.alias}
|
|
70
|
+
\`\`\``,
|
|
71
|
+
`#### Arguments`,
|
|
72
|
+
``,
|
|
73
|
+
...methodInfo.arguments.map((arg) => {
|
|
74
|
+
return renderType(arg, 2, { name: arg.name, optional: arg.optional });
|
|
75
|
+
}),
|
|
76
|
+
`#### Return type`,
|
|
77
|
+
renderType(methodInfo.returnType, 0, undefined),
|
|
78
|
+
].join("\n");
|
|
79
|
+
});
|
|
80
|
+
const result = mdxContent.join("\n\n");
|
|
81
|
+
fs.writeFileSync(filePath, result, { encoding: "utf-8" });
|
|
82
|
+
};
|
|
83
|
+
exports.generateMDX = generateMDX;
|
|
84
|
+
const renderType = (type, indent = 2, argOrProp) => {
|
|
85
|
+
const indentText = " ".repeat(indent);
|
|
86
|
+
const title = `${indentText}${(argOrProp === null || argOrProp === void 0 ? void 0 : argOrProp.name) ? `- **${argOrProp.name}**: ` : ""}\`${type.aliasSymbolescapedName || type.alias}\` ${type.comments ? ` - ${removeLineBreaks(type.comments)}` : ""}`;
|
|
87
|
+
if (type.type === "primitive" || type.type === "literal") {
|
|
88
|
+
return title;
|
|
89
|
+
}
|
|
90
|
+
if (type.type === "object") {
|
|
91
|
+
return (title +
|
|
92
|
+
`\n` +
|
|
93
|
+
(0, prostgles_types_2.getObjectEntries)(type.properties)
|
|
94
|
+
.map(([name, p]) => renderType(p, indent + 2, { name, optional: p.optional }))
|
|
95
|
+
.join("\n"));
|
|
96
|
+
}
|
|
97
|
+
if (type.type === "promise") {
|
|
98
|
+
const innerType = renderType(type.innerType, indent, argOrProp);
|
|
99
|
+
// if (argOrProp?.name) {
|
|
100
|
+
// return [title, innerType].join("\n");
|
|
101
|
+
// }
|
|
102
|
+
return innerType;
|
|
103
|
+
}
|
|
104
|
+
if (type.type === "array") {
|
|
105
|
+
return renderType(type.itemType, indent, argOrProp);
|
|
106
|
+
}
|
|
107
|
+
return title;
|
|
108
|
+
};
|
|
109
|
+
const removeLineBreaks = (str = "") => str
|
|
110
|
+
.split("\n")
|
|
111
|
+
.map((line) => {
|
|
112
|
+
if (!line.trim().endsWith("."))
|
|
113
|
+
return `${line}.`;
|
|
114
|
+
})
|
|
115
|
+
.join(" ");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateDocs.d.ts","sourceRoot":"","sources":["../generateDocs.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const generateServerDocs_1 = require("./generateServerDocs");
|
|
4
|
+
const generateClientDocs_1 = require("./generateClientDocs");
|
|
5
|
+
(0, generateServerDocs_1.generateServerDocs)();
|
|
6
|
+
(0, generateClientDocs_1.generateClientDocs)();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateMarkdown.d.ts","sourceRoot":"","sources":["../generateMarkdown.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,WAAW,aAAc,MAAM,SAsC3C,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateMDX = void 0;
|
|
4
|
+
const prostgles_types_1 = require("prostgles-types");
|
|
5
|
+
const definitions_1 = require("./definitions");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const getAliasWithoutGenerics = (type) => {
|
|
8
|
+
if (type.type === "union")
|
|
9
|
+
return type.types.map(getAliasWithoutGenerics).join(" | ");
|
|
10
|
+
return type.aliasSymbolescapedName || type.alias;
|
|
11
|
+
};
|
|
12
|
+
const generateMDX = (filePath) => {
|
|
13
|
+
const tableHandler = definitions_1.definitions[0];
|
|
14
|
+
const mdxContent = (0, prostgles_types_1.getObjectEntries)(tableHandler.properties).map(([methodName, _methodInfo]) => {
|
|
15
|
+
var _a;
|
|
16
|
+
const methodInfo = (_methodInfo.type === "function"
|
|
17
|
+
? _methodInfo
|
|
18
|
+
: // : _methodInfo.type === "union" ? _methodInfo.types.find((t) => t.type === "function")
|
|
19
|
+
undefined);
|
|
20
|
+
if (!methodInfo)
|
|
21
|
+
return "";
|
|
22
|
+
return [
|
|
23
|
+
`## db.tableName.${methodName}()`,
|
|
24
|
+
(_a = methodInfo.comments) !== null && _a !== void 0 ? _a : "",
|
|
25
|
+
`\`\`\`typescript
|
|
26
|
+
(${methodInfo.arguments
|
|
27
|
+
.map((arg) => `${arg.name}${arg.optional ? "?" : ""}: ${getAliasWithoutGenerics(arg)}`)
|
|
28
|
+
.join(", ")}): ${methodInfo.returnType.aliasSymbolescapedName || methodInfo.returnType.alias}
|
|
29
|
+
\`\`\``,
|
|
30
|
+
`#### Arguments`,
|
|
31
|
+
...methodInfo.arguments.map((arg) => {
|
|
32
|
+
return renderType(arg, 2, { name: arg.name, optional: arg.optional });
|
|
33
|
+
// const firstLine = ` - \`${arg.name}: ${arg.alias || arg.aliasSymbolescapedName}\` - ${arg.comments ?? ""}`;
|
|
34
|
+
// if (arg.type === "object") {
|
|
35
|
+
// return [
|
|
36
|
+
// firstLine,
|
|
37
|
+
// ...getObjectEntries(arg.properties).map(
|
|
38
|
+
// ([name, p]) =>
|
|
39
|
+
// ` - \`${name}: ${p.alias || p.aliasSymbolescapedName}\` - ${p.comments ?? ""}`,
|
|
40
|
+
// ),
|
|
41
|
+
// ].join("\n");
|
|
42
|
+
// }
|
|
43
|
+
// return firstLine;
|
|
44
|
+
}),
|
|
45
|
+
`#### Returns`,
|
|
46
|
+
].join("\n");
|
|
47
|
+
});
|
|
48
|
+
const result = mdxContent.join("\n\n");
|
|
49
|
+
fs.writeFileSync(filePath, result, { encoding: "utf-8" });
|
|
50
|
+
};
|
|
51
|
+
exports.generateMDX = generateMDX;
|
|
52
|
+
const renderType = (type, indent = 2, argOrProp) => {
|
|
53
|
+
var _a;
|
|
54
|
+
const indentText = " ".repeat(indent);
|
|
55
|
+
const title = `${indentText}${(argOrProp === null || argOrProp === void 0 ? void 0 : argOrProp.name) ? `- \`${argOrProp.name}: ` : "`"}${type.aliasSymbolescapedName || type.alias}\``;
|
|
56
|
+
if (type.type === "primitive" || type.type === "literal") {
|
|
57
|
+
return `${title} - ${(_a = type.comments) !== null && _a !== void 0 ? _a : ""}`;
|
|
58
|
+
}
|
|
59
|
+
if (type.type === "object") {
|
|
60
|
+
return [
|
|
61
|
+
`<details>`,
|
|
62
|
+
`<summary>${title}</summary>`,
|
|
63
|
+
...(0, prostgles_types_1.getObjectEntries)(type.properties).map(([name, p]) => renderType(p, indent + 2, { name, optional: p.optional })),
|
|
64
|
+
`</details>`,
|
|
65
|
+
].join("\n");
|
|
66
|
+
}
|
|
67
|
+
return "";
|
|
68
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateServerDocs.d.ts","sourceRoot":"","sources":["../generateServerDocs.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,kBAAkB,YAuE9B,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateServerDocs = void 0;
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const getResolvedTypes_1 = require("./getResolvedTypes");
|
|
7
|
+
const serverTypes_1 = require("./serverTypes");
|
|
8
|
+
const prostgles_types_1 = require("prostgles-types");
|
|
9
|
+
const testFolderPath = `${__dirname}/../../../tests/`;
|
|
10
|
+
const docsFolder = `${__dirname}/../../`;
|
|
11
|
+
const generateServerDocs = () => {
|
|
12
|
+
const serverFilePath = path.resolve(
|
|
13
|
+
// `${testFolderPath}/server/node_modules/prostgles-server/dist/DBSchemaBuilder.d.ts` // "DBOFullyTyped",
|
|
14
|
+
`${testFolderPath}/server/node_modules/prostgles-server/dist/ProstglesTypes.d.ts` // "ProstglesInitOptions",
|
|
15
|
+
);
|
|
16
|
+
const { resolvedTypes: [ProstglesInitOptions], visitedMaps, } = (0, getResolvedTypes_1.getResolvedTypes)({
|
|
17
|
+
filePath: serverFilePath,
|
|
18
|
+
filter: {
|
|
19
|
+
nodeNames: [
|
|
20
|
+
"ProstglesInitOptions",
|
|
21
|
+
// "DBOFullyTyped",
|
|
22
|
+
],
|
|
23
|
+
excludedTypes: [],
|
|
24
|
+
maxDepth: 2,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
if (!ProstglesInitOptions)
|
|
28
|
+
throw new Error("ProstglesInitOptions not found");
|
|
29
|
+
const prostglesInitOpts = serverTypes_1.definitions[0];
|
|
30
|
+
const docs = [
|
|
31
|
+
`# Overview`,
|
|
32
|
+
`Our Isomorphic Typescript API allows connecting to a PostgreSQL database to get a realtime view of the data and schema. Interact with the data with full end-to-end type safety.`,
|
|
33
|
+
`### Installation`,
|
|
34
|
+
`To install the package, run:`,
|
|
35
|
+
`\`\`\`bash`,
|
|
36
|
+
`npm install prostgles-server`,
|
|
37
|
+
`\`\`\``,
|
|
38
|
+
`### Configuration`,
|
|
39
|
+
`To get started, you need to provide a configuration object to the server.`,
|
|
40
|
+
``,
|
|
41
|
+
`Basic example:`,
|
|
42
|
+
`\`\`\`typescript`,
|
|
43
|
+
`import prostgles from "prostgles-server";`,
|
|
44
|
+
`import { DBSchemaGenerated } from "./DBSchemaGenerated";`,
|
|
45
|
+
`prostgles<DBSchemaGenerated>({`,
|
|
46
|
+
` dbConnection: {`,
|
|
47
|
+
` host: "localhost",`,
|
|
48
|
+
` port: 5432,`,
|
|
49
|
+
` database: "postgres"`,
|
|
50
|
+
` user: process.env.PRGL_USER,`,
|
|
51
|
+
` password: process.env.PRGL_PWD`,
|
|
52
|
+
` },`,
|
|
53
|
+
` tsGeneratedTypesDir: __dirname,`,
|
|
54
|
+
` onReady: async ({ dbo }) => {`,
|
|
55
|
+
` try {`,
|
|
56
|
+
` await dbo.items.insert({ name: "a" });`,
|
|
57
|
+
` console.log(await dbo.items.find());`,
|
|
58
|
+
` } catch(err) {`,
|
|
59
|
+
` console.error(err)`,
|
|
60
|
+
` }`,
|
|
61
|
+
` },`,
|
|
62
|
+
`});`,
|
|
63
|
+
`\`\`\``,
|
|
64
|
+
`### Configuration options`,
|
|
65
|
+
...(0, prostgles_types_1.getObjectEntries)(prostglesInitOpts.properties).map(([propName, prop]) => {
|
|
66
|
+
const title = ` - <strong>${propName}</strong> \`${prop.aliasSymbolescapedName || prop.alias}\``;
|
|
67
|
+
const comments = prop.comments || "";
|
|
68
|
+
if (!comments)
|
|
69
|
+
return title;
|
|
70
|
+
return [title, ` ` + comments + " "].join("\n");
|
|
71
|
+
}),
|
|
72
|
+
].join("\n");
|
|
73
|
+
const serverTypesStr = [
|
|
74
|
+
`import type { TS_Type } from "./getSerializableType";`,
|
|
75
|
+
`export const definitions = ${JSON.stringify([ProstglesInitOptions], null, 2)} as const satisfies TS_Type[];`,
|
|
76
|
+
].join("\n");
|
|
77
|
+
fs.writeFileSync(`${docsFolder}/utils/serverTypes.ts`, serverTypesStr, { encoding: "utf-8" });
|
|
78
|
+
fs.writeFileSync(`${docsFolder}SERVER.md`, docs, { encoding: "utf-8" });
|
|
79
|
+
};
|
|
80
|
+
exports.generateServerDocs = generateServerDocs;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TS_Type, VisitedTypesMap } from "./getSerializableType";
|
|
2
|
+
type Args = {
|
|
3
|
+
filePath: string;
|
|
4
|
+
filter?: {
|
|
5
|
+
nodeNames: string[];
|
|
6
|
+
excludedTypes: string[];
|
|
7
|
+
maxDepth?: number;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare const getResolvedTypes: ({ filePath, filter }: Args) => {
|
|
11
|
+
resolvedTypes: TS_Type[];
|
|
12
|
+
visitedMaps: VisitedTypesMap[];
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=getResolvedTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getResolvedTypes.d.ts","sourceRoot":"","sources":["../getResolvedTypes.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGtF,KAAK,IAAI,GAAG;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE;QACP,SAAS,EAAE,MAAM,EAAE,CAAC;QACpB,aAAa,EAAE,MAAM,EAAE,CAAC;QACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH,CAAC;AACF,eAAO,MAAM,gBAAgB,yBAA0B,IAAI;;;CAgC1D,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getResolvedTypes = void 0;
|
|
4
|
+
const ts = require("typescript");
|
|
5
|
+
const getSerializableType_1 = require("./getSerializableType");
|
|
6
|
+
const loadTsFile_1 = require("./loadTsFile");
|
|
7
|
+
const getResolvedTypes = ({ filePath, filter }) => {
|
|
8
|
+
const { checker, sourceFile } = (0, loadTsFile_1.loadTsFile)(filePath);
|
|
9
|
+
const results = [];
|
|
10
|
+
const visitedMaps = [];
|
|
11
|
+
const visit = (node) => {
|
|
12
|
+
// const nodeText = node.getText();
|
|
13
|
+
// if (nodeText.includes("DBOFullyTyped")) {
|
|
14
|
+
// console.log("node.name.text", node.getText());
|
|
15
|
+
// }
|
|
16
|
+
if (ts.isTypeAliasDeclaration(node)) {
|
|
17
|
+
if (!filter || (filter === null || filter === void 0 ? void 0 : filter.nodeNames.includes(node.name.text))) {
|
|
18
|
+
const type1 = checker.getTypeAtLocation(node.type);
|
|
19
|
+
const { resolvedType, visited } = (0, getSerializableType_1.getSerializableType)(type1, checker, undefined, [], filter, 0);
|
|
20
|
+
results.push(resolvedType);
|
|
21
|
+
visitedMaps.push(visited);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
ts.forEachChild(node, visit);
|
|
25
|
+
};
|
|
26
|
+
visit(sourceFile);
|
|
27
|
+
return { resolvedTypes: results, visitedMaps };
|
|
28
|
+
};
|
|
29
|
+
exports.getResolvedTypes = getResolvedTypes;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
type TS_Base = {
|
|
3
|
+
alias?: string;
|
|
4
|
+
aliasSymbolescapedName?: string;
|
|
5
|
+
intersectionParent?: string;
|
|
6
|
+
comments?: string;
|
|
7
|
+
};
|
|
8
|
+
export type TS_Literal = TS_Base & {
|
|
9
|
+
type: "literal";
|
|
10
|
+
value: string;
|
|
11
|
+
};
|
|
12
|
+
export type TS_Primitive = TS_Base & {
|
|
13
|
+
type: "primitive";
|
|
14
|
+
subType: "string" | "number" | "boolean" | "any" | "null" | "undefined";
|
|
15
|
+
};
|
|
16
|
+
export type TS_Object = TS_Base & {
|
|
17
|
+
type: "object";
|
|
18
|
+
properties: Record<string, TS_Type & {
|
|
19
|
+
optional: boolean;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
export type TS_Array = TS_Base & {
|
|
23
|
+
type: "array";
|
|
24
|
+
itemType: TS_Type;
|
|
25
|
+
};
|
|
26
|
+
export type TS_Tuple = TS_Base & {
|
|
27
|
+
type: "tuple";
|
|
28
|
+
itemTypes: TS_Type[];
|
|
29
|
+
};
|
|
30
|
+
export type TS_Function = TS_Base & {
|
|
31
|
+
type: "function";
|
|
32
|
+
arguments: (TS_Type & {
|
|
33
|
+
name: string;
|
|
34
|
+
optional: boolean;
|
|
35
|
+
})[];
|
|
36
|
+
returnType: TS_Type;
|
|
37
|
+
};
|
|
38
|
+
export type TS_Promise = TS_Base & {
|
|
39
|
+
type: "promise";
|
|
40
|
+
innerType: Exclude<TS_Type, TS_Promise>;
|
|
41
|
+
};
|
|
42
|
+
export type TS_Union = TS_Base & {
|
|
43
|
+
type: "union";
|
|
44
|
+
types: TS_Type[];
|
|
45
|
+
};
|
|
46
|
+
export type TS_Reference = TS_Base & {
|
|
47
|
+
type: "reference";
|
|
48
|
+
alias: string;
|
|
49
|
+
};
|
|
50
|
+
export type TS_Type = TS_Primitive | TS_Literal | TS_Object | TS_Array | TS_Tuple | TS_Function | TS_Union | TS_Promise | TS_Reference;
|
|
51
|
+
export type VisitedTypesMap = Map<string, {
|
|
52
|
+
resolvedType: TS_Type;
|
|
53
|
+
type: ts.Type;
|
|
54
|
+
referenceType?: TS_Type;
|
|
55
|
+
}>;
|
|
56
|
+
export declare const getSerializableType: (myType: ts.Type, checker: ts.TypeChecker, visited: VisitedTypesMap | undefined, parentAliases: string[], opts: ResolveTypeOptions | undefined, depth: number) => {
|
|
57
|
+
resolvedType: TS_Type;
|
|
58
|
+
visited: VisitedTypesMap;
|
|
59
|
+
};
|
|
60
|
+
type ResolveTypeOptions = {
|
|
61
|
+
excludedTypes: string[];
|
|
62
|
+
maxDepth?: number;
|
|
63
|
+
};
|
|
64
|
+
export declare const resolveType: (myType: ts.Type, checker: ts.TypeChecker, opts: ResolveTypeOptions) => {
|
|
65
|
+
resolvedType: TS_Type;
|
|
66
|
+
constituentTypes?: TS_Type[] | undefined;
|
|
67
|
+
};
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=getSerializableType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSerializableType.d.ts","sourceRoot":"","sources":["../getSerializableType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAGjC,KAAK,OAAO,GAAG;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG;IACjC,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG;IACnC,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,WAAW,CAAC;CACzE,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG;IAChC,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,OAAO,EAAE,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG;IAClC,IAAI,EAAE,UAAU,CAAC;IACjB,SAAS,EAAE,CAAC,OAAO,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,EAAE,CAAC;IAC7D,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG;IACjC,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,EAAE,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG;IACnC,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,OAAO,GACf,YAAY,GACZ,UAAU,GACV,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,UAAU,GACV,YAAY,CAAC;AAEjB,MAAM,MAAM,eAAe,GAAG,GAAG,CAC/B,MAAM,EACN;IAAE,YAAY,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,CAClE,CAAC;AAEF,eAAO,MAAM,mBAAmB,WACtB,GAAG,IAAI,WACN,GAAG,WAAW,uDAER,MAAM,EAAE,QACjB,kBAAkB,GAAG,SAAS,SAC7B,MAAM;kBACI,OAAO;;CAoUzB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AACF,eAAO,MAAM,WAAW,WACd,GAAG,IAAI,WACN,GAAG,WAAW,QACjB,kBAAkB;kBACP,OAAO;;CAMzB,CAAC"}
|