@iyio/protogen-runtime 0.0.11 → 0.0.13
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/esm/src/lib/default-plugins.js +42 -0
- package/esm/src/lib/default-plugins.js.map +1 -1
- package/esm/src/lib/plugins/actionPlugin.d.ts +40 -0
- package/esm/src/lib/plugins/actionPlugin.js +97 -0
- package/esm/src/lib/plugins/actionPlugin.js.map +1 -0
- package/esm/src/lib/plugins/assignPlugin.d.ts +20 -0
- package/esm/src/lib/plugins/assignPlugin.js +52 -0
- package/esm/src/lib/plugins/assignPlugin.js.map +1 -0
- package/esm/src/lib/plugins/autoPackageIndexPlugin.js +10 -0
- package/esm/src/lib/plugins/autoPackageIndexPlugin.js.map +1 -1
- package/esm/src/lib/plugins/bucketCdkTemplate.js +4 -2
- package/esm/src/lib/plugins/bucketCdkTemplate.js.map +1 -1
- package/esm/src/lib/plugins/bucketPlugin.js +16 -4
- package/esm/src/lib/plugins/bucketPlugin.js.map +1 -1
- package/esm/src/lib/plugins/callablePlugin.d.ts +40 -0
- package/esm/src/lib/plugins/callablePlugin.js +86 -0
- package/esm/src/lib/plugins/callablePlugin.js.map +1 -0
- package/esm/src/lib/plugins/examplePlugin.js +1 -2
- package/esm/src/lib/plugins/examplePlugin.js.map +1 -1
- package/esm/src/lib/plugins/fileWriter.js +3 -2
- package/esm/src/lib/plugins/fileWriter.js.map +1 -1
- package/esm/src/lib/plugins/functionPlugin.js +37 -8
- package/esm/src/lib/plugins/functionPlugin.js.map +1 -1
- package/esm/src/lib/plugins/nextJsAppPlugin.js +14 -5
- package/esm/src/lib/plugins/nextJsAppPlugin.js.map +1 -1
- package/esm/src/lib/plugins/nextJsAppTemplate.js +18 -0
- package/esm/src/lib/plugins/nextJsAppTemplate.js.map +1 -1
- package/esm/src/lib/plugins/nextJsPagePlugin.d.ts +15 -0
- package/esm/src/lib/plugins/nextJsPagePlugin.js +65 -0
- package/esm/src/lib/plugins/nextJsPagePlugin.js.map +1 -0
- package/esm/src/lib/plugins/reactCompPlugin.js +1 -1
- package/esm/src/lib/plugins/reactCompPlugin.js.map +1 -1
- package/esm/src/lib/plugins/serverFnCdkTemplate.d.ts +2 -1
- package/esm/src/lib/plugins/serverFnCdkTemplate.js +10 -3
- package/esm/src/lib/plugins/serverFnCdkTemplate.js.map +1 -1
- package/esm/src/lib/plugins/serverFnPlugin.d.ts +6 -0
- package/esm/src/lib/plugins/serverFnPlugin.js +87 -23
- package/esm/src/lib/plugins/serverFnPlugin.js.map +1 -1
- package/esm/src/lib/plugins/sqlMigrationCdkTemplate.d.ts +5 -0
- package/esm/src/lib/plugins/sqlMigrationCdkTemplate.js +40 -0
- package/esm/src/lib/plugins/sqlMigrationCdkTemplate.js.map +1 -0
- package/esm/src/lib/plugins/sqlMigrationsPlugin.d.ts +39 -0
- package/esm/src/lib/plugins/sqlMigrationsPlugin.js +114 -0
- package/esm/src/lib/plugins/sqlMigrationsPlugin.js.map +1 -0
- package/esm/src/lib/plugins/sqlTablePlugin.d.ts +64 -0
- package/esm/src/lib/plugins/sqlTablePlugin.js +162 -0
- package/esm/src/lib/plugins/sqlTablePlugin.js.map +1 -0
- package/esm/src/lib/plugins/tablePlugin.js +16 -134
- package/esm/src/lib/plugins/tablePlugin.js.map +1 -1
- package/esm/src/lib/plugins/tsProtoNodePlugin.js +1 -1
- package/esm/src/lib/plugins/tsProtoNodePlugin.js.map +1 -1
- package/esm/src/lib/plugins/userPoolPlugin.js +16 -1
- package/esm/src/lib/plugins/userPoolPlugin.js.map +1 -1
- package/esm/src/lib/plugins/zodPlugin.d.ts +3 -0
- package/esm/src/lib/plugins/zodPlugin.js +151 -33
- package/esm/src/lib/plugins/zodPlugin.js.map +1 -1
- package/esm/src/lib/protogen-table-generator.d.ts +39 -0
- package/esm/src/lib/protogen-table-generator.js +181 -0
- package/esm/src/lib/protogen-table-generator.js.map +1 -0
- package/esm/src/lib/runProtogenCliAsync.js +5 -0
- package/esm/src/lib/runProtogenCliAsync.js.map +1 -1
- package/package.json +18 -10
- package/src/lib/default-plugins.js +42 -0
- package/src/lib/default-plugins.js.map +1 -1
- package/src/lib/plugins/actionPlugin.d.ts +40 -0
- package/src/lib/plugins/actionPlugin.js +100 -0
- package/src/lib/plugins/actionPlugin.js.map +1 -0
- package/src/lib/plugins/assignPlugin.d.ts +20 -0
- package/src/lib/plugins/assignPlugin.js +55 -0
- package/src/lib/plugins/assignPlugin.js.map +1 -0
- package/src/lib/plugins/autoPackageIndexPlugin.js +10 -0
- package/src/lib/plugins/autoPackageIndexPlugin.js.map +1 -1
- package/src/lib/plugins/bucketCdkTemplate.js +4 -2
- package/src/lib/plugins/bucketCdkTemplate.js.map +1 -1
- package/src/lib/plugins/bucketPlugin.js +15 -3
- package/src/lib/plugins/bucketPlugin.js.map +1 -1
- package/src/lib/plugins/callablePlugin.d.ts +40 -0
- package/src/lib/plugins/callablePlugin.js +89 -0
- package/src/lib/plugins/callablePlugin.js.map +1 -0
- package/src/lib/plugins/examplePlugin.js +1 -2
- package/src/lib/plugins/examplePlugin.js.map +1 -1
- package/src/lib/plugins/fileWriter.js +3 -2
- package/src/lib/plugins/fileWriter.js.map +1 -1
- package/src/lib/plugins/functionPlugin.js +36 -7
- package/src/lib/plugins/functionPlugin.js.map +1 -1
- package/src/lib/plugins/nextJsAppPlugin.js +13 -4
- package/src/lib/plugins/nextJsAppPlugin.js.map +1 -1
- package/src/lib/plugins/nextJsAppTemplate.js +18 -0
- package/src/lib/plugins/nextJsAppTemplate.js.map +1 -1
- package/src/lib/plugins/nextJsPagePlugin.d.ts +15 -0
- package/src/lib/plugins/nextJsPagePlugin.js +68 -0
- package/src/lib/plugins/nextJsPagePlugin.js.map +1 -0
- package/src/lib/plugins/reactCompPlugin.js +1 -1
- package/src/lib/plugins/reactCompPlugin.js.map +1 -1
- package/src/lib/plugins/serverFnCdkTemplate.d.ts +2 -1
- package/src/lib/plugins/serverFnCdkTemplate.js +10 -3
- package/src/lib/plugins/serverFnCdkTemplate.js.map +1 -1
- package/src/lib/plugins/serverFnPlugin.d.ts +6 -0
- package/src/lib/plugins/serverFnPlugin.js +85 -21
- package/src/lib/plugins/serverFnPlugin.js.map +1 -1
- package/src/lib/plugins/sqlMigrationCdkTemplate.d.ts +5 -0
- package/src/lib/plugins/sqlMigrationCdkTemplate.js +44 -0
- package/src/lib/plugins/sqlMigrationCdkTemplate.js.map +1 -0
- package/src/lib/plugins/sqlMigrationsPlugin.d.ts +39 -0
- package/src/lib/plugins/sqlMigrationsPlugin.js +117 -0
- package/src/lib/plugins/sqlMigrationsPlugin.js.map +1 -0
- package/src/lib/plugins/sqlTablePlugin.d.ts +64 -0
- package/src/lib/plugins/sqlTablePlugin.js +165 -0
- package/src/lib/plugins/sqlTablePlugin.js.map +1 -0
- package/src/lib/plugins/tablePlugin.js +15 -133
- package/src/lib/plugins/tablePlugin.js.map +1 -1
- package/src/lib/plugins/tsProtoNodePlugin.js +1 -1
- package/src/lib/plugins/tsProtoNodePlugin.js.map +1 -1
- package/src/lib/plugins/userPoolPlugin.js +16 -1
- package/src/lib/plugins/userPoolPlugin.js.map +1 -1
- package/src/lib/plugins/zodPlugin.d.ts +3 -0
- package/src/lib/plugins/zodPlugin.js +149 -31
- package/src/lib/plugins/zodPlugin.js.map +1 -1
- package/src/lib/protogen-table-generator.d.ts +39 -0
- package/src/lib/protogen-table-generator.js +185 -0
- package/src/lib/protogen-table-generator.js.map +1 -0
- package/src/lib/runProtogenCliAsync.js +5 -0
- package/src/lib/runProtogenCliAsync.js.map +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ProtoPipelineConfigurablePlugin } from "@iyio/protogen";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
declare const SqlMigrationsConfig: z.ZodObject<{
|
|
4
|
+
/**
|
|
5
|
+
* @default .sqlMigrationsPackage
|
|
6
|
+
*/
|
|
7
|
+
sqlMigrationsPath: z.ZodOptional<z.ZodString>;
|
|
8
|
+
/**
|
|
9
|
+
* @default "sql-migrations"
|
|
10
|
+
*/
|
|
11
|
+
sqlMigrationsPackage: z.ZodOptional<z.ZodString>;
|
|
12
|
+
/**
|
|
13
|
+
* @default "sql-migrations-index.ts"
|
|
14
|
+
*/
|
|
15
|
+
sqlMigrationsIndexFilename: z.ZodOptional<z.ZodString>;
|
|
16
|
+
/**
|
|
17
|
+
* If defined a CDK construct file will be generated that can be used to deploy the
|
|
18
|
+
* tables
|
|
19
|
+
*/
|
|
20
|
+
sqlMigrationCdkConstructFile: z.ZodOptional<z.ZodString>;
|
|
21
|
+
/**
|
|
22
|
+
* @default "SqlMigrate"
|
|
23
|
+
*/
|
|
24
|
+
sqlMigrationCdkConstructClassName: z.ZodOptional<z.ZodString>;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
sqlMigrationsPath?: string | undefined;
|
|
27
|
+
sqlMigrationsPackage?: string | undefined;
|
|
28
|
+
sqlMigrationsIndexFilename?: string | undefined;
|
|
29
|
+
sqlMigrationCdkConstructFile?: string | undefined;
|
|
30
|
+
sqlMigrationCdkConstructClassName?: string | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
sqlMigrationsPath?: string | undefined;
|
|
33
|
+
sqlMigrationsPackage?: string | undefined;
|
|
34
|
+
sqlMigrationsIndexFilename?: string | undefined;
|
|
35
|
+
sqlMigrationCdkConstructFile?: string | undefined;
|
|
36
|
+
sqlMigrationCdkConstructClassName?: string | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
export declare const sqlMigrationsPlugin: ProtoPipelineConfigurablePlugin<typeof SqlMigrationsConfig>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sqlMigrationsPlugin = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@iyio/common");
|
|
6
|
+
const node_common_1 = require("@iyio/node-common");
|
|
7
|
+
const protogen_1 = require("@iyio/protogen");
|
|
8
|
+
const promises_1 = require("fs/promises");
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
|
+
const SqlMigrationsConfig = zod_1.z.object({
|
|
11
|
+
/**
|
|
12
|
+
* @default .sqlMigrationsPackage
|
|
13
|
+
*/
|
|
14
|
+
sqlMigrationsPath: zod_1.z.string().optional(),
|
|
15
|
+
/**
|
|
16
|
+
* @default "sql-migrations"
|
|
17
|
+
*/
|
|
18
|
+
sqlMigrationsPackage: zod_1.z.string().optional(),
|
|
19
|
+
/**
|
|
20
|
+
* @default "sql-migrations-index.ts"
|
|
21
|
+
*/
|
|
22
|
+
sqlMigrationsIndexFilename: zod_1.z.string().optional(),
|
|
23
|
+
/**
|
|
24
|
+
* If defined a CDK construct file will be generated that can be used to deploy the
|
|
25
|
+
* tables
|
|
26
|
+
*/
|
|
27
|
+
sqlMigrationCdkConstructFile: zod_1.z.string().optional(),
|
|
28
|
+
/**
|
|
29
|
+
* @default "SqlMigrate"
|
|
30
|
+
*/
|
|
31
|
+
sqlMigrationCdkConstructClassName: zod_1.z.string().optional(),
|
|
32
|
+
});
|
|
33
|
+
exports.sqlMigrationsPlugin = {
|
|
34
|
+
configScheme: SqlMigrationsConfig,
|
|
35
|
+
generationStage: 1,
|
|
36
|
+
generate: ({ outputs, tab, log, nodes, namespace, packagePaths, libStyle, importMap, }, { sqlMigrationsPackage = 'sql-migrations', sqlMigrationsPath = sqlMigrationsPackage, sqlMigrationsIndexFilename = 'sql-migrations-index.ts', sqlMigrationCdkConstructClassName = 'SqlMigrate', sqlMigrationCdkConstructFile = libStyle === 'nx' ? `packages/cdk/src/${sqlMigrationCdkConstructClassName}.ts` : undefined, }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
const schemeOutput = outputs.find(o => { var _a; return ((_a = o.metadata) === null || _a === void 0 ? void 0 : _a['sqlTableSchemaPath']) === true; });
|
|
38
|
+
if (!schemeOutput) {
|
|
39
|
+
log('No schemeOutput found');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const supported = nodes.filter(node => node.types.some(t => t.type === 'sqlMigrations'));
|
|
43
|
+
log(`${supported.length} supported node(s)`);
|
|
44
|
+
if (!supported.length) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const { path, packageName, removePackage } = (0, protogen_1.getProtoPluginPackAndPath)(namespace, sqlMigrationsPackage, sqlMigrationsPath, libStyle, { packagePaths, indexFilename: sqlMigrationsIndexFilename });
|
|
48
|
+
// migrations
|
|
49
|
+
const content = (yield (0, promises_1.readFile)(schemeOutput.path)).toString();
|
|
50
|
+
for (const node of supported) {
|
|
51
|
+
if (!node.children) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const out = [];
|
|
55
|
+
let prevSchemePath = null;
|
|
56
|
+
for (const cn in node.children) {
|
|
57
|
+
const child = node.children[cn];
|
|
58
|
+
if (!child || child.isContent || child.special) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const name = (node.name + '-' + (0, common_1.getFileName)(child.name)).replace(/[^a-z0-9_-]/gi, '');
|
|
62
|
+
const schemePath = (0, common_1.joinPaths)(path, name + '.prisma');
|
|
63
|
+
const sqlUpPath = (0, common_1.joinPaths)(path, name + '-up.sql');
|
|
64
|
+
const sqlDownPath = (0, common_1.joinPaths)(path, name + '-down.sql');
|
|
65
|
+
const [schemeExists, sqlUpExists, sqlDownExists] = yield Promise.all([
|
|
66
|
+
(0, node_common_1.pathExistsAsync)(schemePath),
|
|
67
|
+
(0, node_common_1.pathExistsAsync)(sqlUpPath),
|
|
68
|
+
(0, node_common_1.pathExistsAsync)(sqlDownPath),
|
|
69
|
+
]);
|
|
70
|
+
if (!schemeExists) {
|
|
71
|
+
yield (0, promises_1.writeFile)(schemePath, content);
|
|
72
|
+
}
|
|
73
|
+
let sqlUp;
|
|
74
|
+
let sqlDown;
|
|
75
|
+
if (sqlUpExists) {
|
|
76
|
+
sqlUp = (yield (0, promises_1.readFile)(sqlUpPath)).toString();
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
sqlUp = yield (0, node_common_1.execAsync)(`npx prisma migrate diff ${prevSchemePath ? `--from-schema-datamodel ${prevSchemePath}` : '--from-empty'} --to-schema-datamodel ${schemePath} --script`);
|
|
80
|
+
yield (0, promises_1.writeFile)(sqlUpPath, sqlUp);
|
|
81
|
+
}
|
|
82
|
+
if (sqlDownExists) {
|
|
83
|
+
sqlDown = (yield (0, promises_1.readFile)(sqlDownPath)).toString();
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
sqlDown = yield (0, node_common_1.execAsync)(`npx prisma migrate diff ${prevSchemePath ? `--to-schema-datamodel ${prevSchemePath}` : '--to-empty'} --from-schema-datamodel ${schemePath} --script`);
|
|
87
|
+
yield (0, promises_1.writeFile)(sqlDownPath, sqlDown);
|
|
88
|
+
}
|
|
89
|
+
out.push({ name, up: sqlUp, down: sqlDown });
|
|
90
|
+
prevSchemePath = schemePath;
|
|
91
|
+
}
|
|
92
|
+
if (out.length) {
|
|
93
|
+
outputs.push({
|
|
94
|
+
path: (0, common_1.joinPaths)(path, node.name + '.ts'),
|
|
95
|
+
content: `export const ${node.name}=${JSON.stringify(out, null, tab)}`
|
|
96
|
+
});
|
|
97
|
+
importMap[node.name] = packageName;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (outputs.length) {
|
|
101
|
+
// add index file
|
|
102
|
+
outputs.push({
|
|
103
|
+
path: (0, common_1.joinPaths)(path, sqlMigrationsIndexFilename),
|
|
104
|
+
content: '',
|
|
105
|
+
isPackageIndex: true,
|
|
106
|
+
generator: {
|
|
107
|
+
root: path,
|
|
108
|
+
generator: protogen_1.protoGenerateTsIndex
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
removePackage();
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=sqlMigrationsPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlMigrationsPlugin.js","sourceRoot":"","sources":["../../../../../../packages/protogen-runtime/src/lib/plugins/sqlMigrationsPlugin.ts"],"names":[],"mappings":";;;;AAAA,yCAAoE;AACpE,mDAA+D;AAC/D,6CAAkH;AAClH,0CAAkD;AAClD,6BAAwB;AAExB,MAAM,mBAAmB,GAAC,OAAC,CAAC,MAAM,CAClC;IACI;;OAEG;IACH,iBAAiB,EAAC,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAEvC;;OAEG;IACH,oBAAoB,EAAC,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAE1C;;OAEG;IACH,0BAA0B,EAAC,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAEhD;;;OAGG;IACH,4BAA4B,EAAC,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAElD;;OAEG;IACH,iCAAiC,EAAC,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC1D,CAAC,CAAA;AAEW,QAAA,mBAAmB,GAChC;IACI,YAAY,EAAC,mBAAmB;IAChC,eAAe,EAAC,CAAC;IACjB,QAAQ,EAAC,CAAO,EACZ,OAAO,EACP,GAAG,EACH,GAAG,EACH,KAAK,EACL,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,SAAS,GACZ,EAAC,EACE,oBAAoB,GAAC,gBAAgB,EACrC,iBAAiB,GAAC,oBAAoB,EACtC,0BAA0B,GAAC,yBAAyB,EACpD,iCAAiC,GAAC,YAAY,EAC9C,4BAA4B,GAAC,QAAQ,KAAG,IAAI,CAAA,CAAC,CAAA,oBAAoB,iCAAiC,KAAK,CAAA,CAAC,CAAA,SAAS,GAEpH,EAAC,EAAE;QAEA,MAAM,YAAY,GAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA,EAAE,WAAA,OAAA,CAAA,MAA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Config: z.ZodObject<{
|
|
4
|
+
/**
|
|
5
|
+
* @default .sqlTablePackage
|
|
6
|
+
*/
|
|
7
|
+
sqlTablePath: z.ZodOptional<z.ZodString>;
|
|
8
|
+
/**
|
|
9
|
+
* @default "sql-tables"
|
|
10
|
+
*/
|
|
11
|
+
sqlTablePackage: z.ZodOptional<z.ZodString>;
|
|
12
|
+
/**
|
|
13
|
+
* @default "sql-tables.ts"
|
|
14
|
+
*/
|
|
15
|
+
sqlTableFilename: z.ZodOptional<z.ZodString>;
|
|
16
|
+
/**
|
|
17
|
+
* @default "sql-tables-index.ts"
|
|
18
|
+
*/
|
|
19
|
+
sqlTableIndexFilename: z.ZodOptional<z.ZodString>;
|
|
20
|
+
/**
|
|
21
|
+
* The sql data source or dialect used by prisma
|
|
22
|
+
* @default "postgresql"
|
|
23
|
+
*/
|
|
24
|
+
sqlTableDialect: z.ZodOptional<z.ZodString>;
|
|
25
|
+
/**
|
|
26
|
+
* Path to the Prisma scheme file
|
|
27
|
+
* @default "schema.prisma"
|
|
28
|
+
*/
|
|
29
|
+
sqlTableSchemaPath: z.ZodOptional<z.ZodString>;
|
|
30
|
+
/**
|
|
31
|
+
* @default '@iyio/common'
|
|
32
|
+
*/
|
|
33
|
+
dataTableDescriptionPackage: z.ZodOptional<z.ZodString>;
|
|
34
|
+
/**
|
|
35
|
+
* @default 'allSqlTables'
|
|
36
|
+
*/
|
|
37
|
+
allSqlTableArrayName: z.ZodOptional<z.ZodString>;
|
|
38
|
+
/**
|
|
39
|
+
* A comma separated list of properties that should be converted as long strings.
|
|
40
|
+
*/
|
|
41
|
+
longStringProps: z.ZodOptional<z.ZodString>;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
sqlTablePath?: string | undefined;
|
|
44
|
+
sqlTablePackage?: string | undefined;
|
|
45
|
+
sqlTableFilename?: string | undefined;
|
|
46
|
+
sqlTableIndexFilename?: string | undefined;
|
|
47
|
+
sqlTableDialect?: string | undefined;
|
|
48
|
+
sqlTableSchemaPath?: string | undefined;
|
|
49
|
+
dataTableDescriptionPackage?: string | undefined;
|
|
50
|
+
allSqlTableArrayName?: string | undefined;
|
|
51
|
+
longStringProps?: string | undefined;
|
|
52
|
+
}, {
|
|
53
|
+
sqlTablePath?: string | undefined;
|
|
54
|
+
sqlTablePackage?: string | undefined;
|
|
55
|
+
sqlTableFilename?: string | undefined;
|
|
56
|
+
sqlTableIndexFilename?: string | undefined;
|
|
57
|
+
sqlTableDialect?: string | undefined;
|
|
58
|
+
sqlTableSchemaPath?: string | undefined;
|
|
59
|
+
dataTableDescriptionPackage?: string | undefined;
|
|
60
|
+
allSqlTableArrayName?: string | undefined;
|
|
61
|
+
longStringProps?: string | undefined;
|
|
62
|
+
}>;
|
|
63
|
+
export declare const sqlTablePlugin: ProtoPipelineConfigurablePlugin<typeof SqlTableConfig>;
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sqlTablePlugin = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@iyio/common");
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const protogen_table_generator_1 = require("../protogen-table-generator");
|
|
8
|
+
const SqlTableConfig = zod_1.z.object({
|
|
9
|
+
/**
|
|
10
|
+
* @default .sqlTablePackage
|
|
11
|
+
*/
|
|
12
|
+
sqlTablePath: zod_1.z.string().optional(),
|
|
13
|
+
/**
|
|
14
|
+
* @default "sql-tables"
|
|
15
|
+
*/
|
|
16
|
+
sqlTablePackage: zod_1.z.string().optional(),
|
|
17
|
+
/**
|
|
18
|
+
* @default "sql-tables.ts"
|
|
19
|
+
*/
|
|
20
|
+
sqlTableFilename: zod_1.z.string().optional(),
|
|
21
|
+
/**
|
|
22
|
+
* @default "sql-tables-index.ts"
|
|
23
|
+
*/
|
|
24
|
+
sqlTableIndexFilename: zod_1.z.string().optional(),
|
|
25
|
+
/**
|
|
26
|
+
* The sql data source or dialect used by prisma
|
|
27
|
+
* @default "postgresql"
|
|
28
|
+
*/
|
|
29
|
+
sqlTableDialect: zod_1.z.string().optional(),
|
|
30
|
+
/**
|
|
31
|
+
* Path to the Prisma scheme file
|
|
32
|
+
* @default "schema.prisma"
|
|
33
|
+
*/
|
|
34
|
+
sqlTableSchemaPath: zod_1.z.string().optional(),
|
|
35
|
+
/**
|
|
36
|
+
* @default '@iyio/common'
|
|
37
|
+
*/
|
|
38
|
+
dataTableDescriptionPackage: zod_1.z.string().optional(),
|
|
39
|
+
/**
|
|
40
|
+
* @default 'allSqlTables'
|
|
41
|
+
*/
|
|
42
|
+
allSqlTableArrayName: zod_1.z.string().optional(),
|
|
43
|
+
/**
|
|
44
|
+
* A comma separated list of properties that should be converted as long strings.
|
|
45
|
+
*/
|
|
46
|
+
longStringProps: zod_1.z.string().optional(),
|
|
47
|
+
});
|
|
48
|
+
exports.sqlTablePlugin = {
|
|
49
|
+
configScheme: SqlTableConfig,
|
|
50
|
+
generate: (context, _a) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
+
var _b, _c;
|
|
52
|
+
var { sqlTablePackage = 'sql-tables', sqlTableFilename = 'sql-tables.ts', sqlTablePath = sqlTablePackage, sqlTableIndexFilename = 'sql-tables-index.ts', sqlTableDialect = 'postgresql', sqlTableSchemaPath = 'schema.prisma', dataTableDescriptionPackage = '@iyio/common', allSqlTableArrayName = 'allSqlTables', longStringProps } = _a, tsConfig = tslib_1.__rest(_a, ["sqlTablePackage", "sqlTableFilename", "sqlTablePath", "sqlTableIndexFilename", "sqlTableDialect", "sqlTableSchemaPath", "dataTableDescriptionPackage", "allSqlTableArrayName", "longStringProps"]);
|
|
53
|
+
const result = yield (0, protogen_table_generator_1.generateProtoTable)(context, Object.assign({ pluginName: 'sqlTablePlugin', supportedTypes: ['sqlTable'], paramNameSuffix: 'Sql', tableType: 'sql', tablePath: sqlTablePath, tablePackage: sqlTablePackage, tableFilename: sqlTableFilename, tableIndexFilename: sqlTableIndexFilename, dataTableDescriptionPackage, allTableArrayName: allSqlTableArrayName }, tsConfig));
|
|
54
|
+
if (!result) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const schemeOutput = [];
|
|
58
|
+
schemeOutput.unshift(`
|
|
59
|
+
generator client {
|
|
60
|
+
provider = "prisma-client-js"
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
datasource db {
|
|
64
|
+
provider = "${sqlTableDialect}"
|
|
65
|
+
url = "localhost"
|
|
66
|
+
}
|
|
67
|
+
`);
|
|
68
|
+
const longProps = longStringProps ? longStringProps.split(',').map(s => s.trim()) : [];
|
|
69
|
+
for (const table of result.tables) {
|
|
70
|
+
const node = table.node;
|
|
71
|
+
const name = node.name;
|
|
72
|
+
schemeOutput.push(`model ${name} {`);
|
|
73
|
+
if (node.children) {
|
|
74
|
+
for (const prop in node.children) {
|
|
75
|
+
const child = node.children[prop];
|
|
76
|
+
if (!child || child.special || child.isContent) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const type = getSqlType(child);
|
|
80
|
+
const maxLength = getSqlMaxLength(child, longProps);
|
|
81
|
+
if (type) {
|
|
82
|
+
schemeOutput.push(`${context.tab}${prop} ${type}${((_b = child.types[0]) === null || _b === void 0 ? void 0 : _b.isArray) ? '[]' : child.optional ? '?' : ''}${prop === table.primaryKey ? type === 'Int' ? ' @id @default(autoincrement())' : ' @id' : ''}${type === 'String' && maxLength !== null ? ` @db.VarChar(${maxLength})` : ''}`);
|
|
83
|
+
if (child.refType) {
|
|
84
|
+
const refTable = result.tables.find(t => { var _a; return t.name === ((_a = child.refType) === null || _a === void 0 ? void 0 : _a.type); });
|
|
85
|
+
if (refTable) {
|
|
86
|
+
const refName = (prop.endsWith('Id') && prop.length > 2) ? prop.substring(0, prop.length - 2) : prop + 'Ref';
|
|
87
|
+
schemeOutput.push(`${context.tab}${refName} ${child.refType.type}${child.optional ? '?' : ''} @relation(fields:[${[prop]}],references:[${refTable.primaryKey}])`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const refTable = result.tables.find(t => t.name === child.type);
|
|
93
|
+
if (refTable) {
|
|
94
|
+
schemeOutput.push(`${context.tab}${prop} ${child.type}${((_c = child.types[0]) === null || _c === void 0 ? void 0 : _c.isArray) ? '[]' : child.optional ? '?' : ''}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (table.indexes) {
|
|
100
|
+
for (const index of table.indexes) {
|
|
101
|
+
schemeOutput.push(`\n${context.tab}// ${index.name} - index`);
|
|
102
|
+
schemeOutput.push(`${context.tab}@@index([${index.primary}${index.sort ? ',' + index.sort : ''}])`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
schemeOutput.push('}\n');
|
|
106
|
+
}
|
|
107
|
+
context.outputs.push({
|
|
108
|
+
path: (0, common_1.joinPaths)(result.path, sqlTableSchemaPath),
|
|
109
|
+
content: schemeOutput.join('\n'),
|
|
110
|
+
metadata: { sqlTableSchemaPath: true }
|
|
111
|
+
});
|
|
112
|
+
})
|
|
113
|
+
};
|
|
114
|
+
const sqlTypeMap = {
|
|
115
|
+
string: 'String',
|
|
116
|
+
int: 'Int',
|
|
117
|
+
bool: 'Boolean',
|
|
118
|
+
boolean: 'Boolean',
|
|
119
|
+
number: 'Float',
|
|
120
|
+
bigInt: 'BigInt',
|
|
121
|
+
map: 'Json',
|
|
122
|
+
any: 'Json',
|
|
123
|
+
stringMap: 'Json',
|
|
124
|
+
numberMap: 'Json',
|
|
125
|
+
booleanMap: 'Json',
|
|
126
|
+
dateMap: 'Json',
|
|
127
|
+
bigIntMap: 'Json',
|
|
128
|
+
};
|
|
129
|
+
const getSqlType = (node) => {
|
|
130
|
+
return sqlTypeMap[node.type];
|
|
131
|
+
};
|
|
132
|
+
const getSqlMaxLength = (node, longProps) => {
|
|
133
|
+
var _a, _b, _c;
|
|
134
|
+
const maxChild = (_a = node.children) === null || _a === void 0 ? void 0 : _a['max'];
|
|
135
|
+
if (maxChild) {
|
|
136
|
+
const n = parseNum(node.value);
|
|
137
|
+
if (n !== undefined) {
|
|
138
|
+
return n;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (longProps.includes(node.name) || parseBool((_c = (_b = node.children) === null || _b === void 0 ? void 0 : _b['long']) === null || _c === void 0 ? void 0 : _c.value, false)) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
return 255;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const parseNum = (str) => {
|
|
149
|
+
if (!str) {
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
const n = Number(str);
|
|
153
|
+
return isFinite(n) ? n : undefined;
|
|
154
|
+
};
|
|
155
|
+
const parseBool = (value, defaultValue) => {
|
|
156
|
+
if (!value) {
|
|
157
|
+
return defaultValue;
|
|
158
|
+
}
|
|
159
|
+
value = value.trim();
|
|
160
|
+
if (!value) {
|
|
161
|
+
return defaultValue;
|
|
162
|
+
}
|
|
163
|
+
return Boolean(value);
|
|
164
|
+
};
|
|
165
|
+
//# sourceMappingURL=sqlTablePlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlTablePlugin.js","sourceRoot":"","sources":["../../../../../../packages/protogen-runtime/src/lib/plugins/sqlTablePlugin.ts"],"names":[],"mappings":";;;;AAAA,yCAAyC;AAEzC,6BAAwB;AACxB,0EAAiE;AAEjE,MAAM,cAAc,GAAC,OAAC,CAAC,MAAM,CAC7B;IACI;;OAEG;IACH,YAAY,EAAC,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAElC;;OAEG;IACH,eAAe,EAAC,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAErC;;OAEG;IACH,gBAAgB,EAAC,OAA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AG,CAAC,KAAK,EAAC;QACN,OAAO,YAAY,CAAC;KACvB;IACD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC,CAAA"}
|
|
@@ -2,15 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tablePlugin = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("@iyio/common");
|
|
6
|
-
const protogen_1 = require("@iyio/protogen");
|
|
7
5
|
const zod_1 = require("zod");
|
|
6
|
+
const protogen_table_generator_1 = require("../protogen-table-generator");
|
|
8
7
|
const sharedTsConfig_1 = require("../sharedTsConfig");
|
|
9
8
|
const tableCdkTemplate_1 = require("./tableCdkTemplate");
|
|
10
9
|
const TablePluginConfig = zod_1.z.object({
|
|
11
|
-
/**
|
|
12
|
-
* @default .tablePackage
|
|
13
|
-
*/
|
|
14
10
|
tablePath: zod_1.z.string().optional(),
|
|
15
11
|
/**
|
|
16
12
|
* @default "tables.ts"
|
|
@@ -48,136 +44,22 @@ const TablePluginConfig = zod_1.z.object({
|
|
|
48
44
|
}).merge(sharedTsConfig_1.SharedTsPluginConfigScheme);
|
|
49
45
|
exports.tablePlugin = {
|
|
50
46
|
configScheme: TablePluginConfig,
|
|
51
|
-
generate: (
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
addImport('DataTableDescription', dataTableDescriptionPackage);
|
|
63
|
-
addImport('DataTableIndex', dataTableDescriptionPackage);
|
|
64
|
-
}
|
|
65
|
-
log(`${supported.length} supported node(s)`);
|
|
66
|
-
const out = [];
|
|
67
|
-
const tableNames = [];
|
|
68
|
-
const tableInfos = [];
|
|
69
|
-
for (const node of supported) {
|
|
70
|
-
const name = node.name;
|
|
71
|
-
const paramName = (0, protogen_1.protoGetParamName)(name + 'Table');
|
|
72
|
-
importMap[name + 'Table'] = packageName;
|
|
73
|
-
importMap[name + 'TableIndexMap'] = packageName;
|
|
74
|
-
tableNames.push(name + 'Table');
|
|
75
|
-
tableInfos.push({ name: name + 'Table', paramName });
|
|
76
|
-
log(`table - ${name}Table`);
|
|
77
|
-
const props = (0, protogen_1.protoGetChildren)(node, false);
|
|
78
|
-
out.push('');
|
|
79
|
-
if (node.comment) {
|
|
80
|
-
out.push((0, protogen_1.protoFormatTsComment)(node.comment, ''));
|
|
81
|
-
}
|
|
82
|
-
addImport(name);
|
|
83
|
-
out.push(`export const ${name}Table:DataTableDescription<${name}>={`);
|
|
84
|
-
out.push(`${tab}name:${JSON.stringify(name)},`);
|
|
85
|
-
const primary = props.find(n => { var _a; return (_a = n.children) === null || _a === void 0 ? void 0 : _a['primaryKey']; });
|
|
86
|
-
out.push(`${tab}primaryKey:${primary ? JSON.stringify(primary.name) : '"id"'},`);
|
|
87
|
-
if (tableUseParamIds) {
|
|
88
|
-
(0, protogen_1.protoAddContextParam)(name + 'Table', paramPackage, paramMap, importMap);
|
|
89
|
-
addImport(paramName, paramPackage);
|
|
90
|
-
out.push(`${tab}tableIdParam:${paramName},`);
|
|
91
|
-
}
|
|
92
|
-
const config = (_d = (_c = (_b = node.children) === null || _b === void 0 ? void 0 : _b['$table']) === null || _c === void 0 ? void 0 : _c.children) !== null && _d !== void 0 ? _d : {};
|
|
93
|
-
let configValue;
|
|
94
|
-
configValue = (_f = (_e = config['scheme']) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : (0, sharedTsConfig_1.getTsSchemeName)(name, tsConfig);
|
|
95
|
-
if (importMap[configValue]) {
|
|
96
|
-
addImport(configValue);
|
|
97
|
-
out.push(`${tab}scheme:${configValue},`);
|
|
98
|
-
}
|
|
99
|
-
if (configValue = (_g = config['mountPath']) === null || _g === void 0 ? void 0 : _g.value) {
|
|
100
|
-
out.push(`${tab}mountPath:${JSON.stringify(configValue)},`);
|
|
101
|
-
}
|
|
102
|
-
if (configValue = (_h = config['isReadonly']) === null || _h === void 0 ? void 0 : _h.value) {
|
|
103
|
-
out.push(`${tab}isReadonly:${JSON.stringify(Boolean(configValue))},`);
|
|
104
|
-
}
|
|
105
|
-
if (configValue = (_k = (_j = config['watchable']) === null || _j === void 0 ? void 0 : _j.value) === null || _k === void 0 ? void 0 : _k.replace(common_1.notWordRegex, '')) {
|
|
106
|
-
out.push(`${tab}watchable:${JSON.stringify(Boolean(configValue))},`);
|
|
107
|
-
}
|
|
108
|
-
if (configValue = (_m = (_l = config['defaultOrderProp']) === null || _l === void 0 ? void 0 : _l.value) === null || _m === void 0 ? void 0 : _m.replace(common_1.notWordRegex, '')) {
|
|
109
|
-
out.push(`${tab}defaultOrderProp:${JSON.stringify(configValue)},`);
|
|
110
|
-
}
|
|
111
|
-
if (configValue = (_p = (_o = config['defaultOrderDesc']) === null || _o === void 0 ? void 0 : _o.value) === null || _p === void 0 ? void 0 : _p.replace(common_1.notWordRegex, '')) {
|
|
112
|
-
out.push(`${tab}defaultOrderDesc:${JSON.stringify(Boolean(configValue))},`);
|
|
113
|
-
}
|
|
114
|
-
if (configValue = (_s = (_r = (_q = config['ttlProp']) === null || _q === void 0 ? void 0 : _q.value) === null || _r === void 0 ? void 0 : _r.replace(common_1.notWordRegex, '')) !== null && _s !== void 0 ? _s : (_t = props.find(p => p.name === 'ttl')) === null || _t === void 0 ? void 0 : _t.name) {
|
|
115
|
-
out.push(`${tab}ttlProp:${JSON.stringify(configValue)},`);
|
|
116
|
-
}
|
|
117
|
-
if (configValue = (_v = (_u = config['updateVersionProp']) === null || _u === void 0 ? void 0 : _u.value) !== null && _v !== void 0 ? _v : (_w = props.find(p => p.name === 'uv')) === null || _w === void 0 ? void 0 : _w.name) {
|
|
118
|
-
out.push(`${tab}updateVersionProp:${JSON.stringify(configValue)},`);
|
|
119
|
-
}
|
|
120
|
-
const indexes = (0, protogen_1.protoGetChildrenByName)((_x = node.children) === null || _x === void 0 ? void 0 : _x['$table'], 'index', false);
|
|
121
|
-
const indexOut = [];
|
|
122
|
-
if (indexes.length) {
|
|
123
|
-
out.push(`${tab}indexes:[`);
|
|
124
|
-
for (let i = 0; i < indexes.length; i++) {
|
|
125
|
-
const index = indexes[i];
|
|
126
|
-
const indexName = index.value || 'index' + i;
|
|
127
|
-
indexOut.push(`${tab}${JSON.stringify(indexName)}:${name}Table.indexes?.[${i}] as DataTableIndex,`);
|
|
128
|
-
out.push(`${tab}${tab}{`);
|
|
129
|
-
out.push(`${tab}${tab}${tab}name:${JSON.stringify(indexName)},`);
|
|
130
|
-
const primaryProp = (_0 = (_z = (_y = index.children) === null || _y === void 0 ? void 0 : _y['primary']) === null || _z === void 0 ? void 0 : _z.value) === null || _0 === void 0 ? void 0 : _0.replace(common_1.notWordRegex, '');
|
|
131
|
-
out.push(`${tab}${tab}${tab}primary:${JSON.stringify(primaryProp !== null && primaryProp !== void 0 ? primaryProp : indexName)},`);
|
|
132
|
-
const sortProp = (_3 = (_2 = (_1 = index.children) === null || _1 === void 0 ? void 0 : _1['sort']) === null || _2 === void 0 ? void 0 : _2.value) === null || _3 === void 0 ? void 0 : _3.replace(common_1.notWordRegex, '');
|
|
133
|
-
if (sortProp) {
|
|
134
|
-
out.push(`${tab}${tab}${tab}sort:${JSON.stringify(sortProp)},`);
|
|
135
|
-
}
|
|
136
|
-
if ((_4 = index.children) === null || _4 === void 0 ? void 0 : _4['includeAll']) {
|
|
137
|
-
out.push(`${tab}${tab}${tab}includeAll:true,`);
|
|
138
|
-
}
|
|
139
|
-
const includeProps = (0, protogen_1.protoGetChildren)((_5 = index.children) === null || _5 === void 0 ? void 0 : _5['include'], false);
|
|
140
|
-
if (includeProps.length) {
|
|
141
|
-
out.push(`${tab}${tab}${tab}include:[`);
|
|
142
|
-
for (const incProp of includeProps) {
|
|
143
|
-
out.push(`${tab}${tab}${tab}${tab}${JSON.stringify(incProp.name)},`);
|
|
144
|
-
}
|
|
145
|
-
out.push(`${tab}${tab}${tab}],`);
|
|
146
|
-
}
|
|
147
|
-
out.push(`${tab}${tab}},`);
|
|
148
|
-
}
|
|
149
|
-
out.push(`${tab}],`);
|
|
150
|
-
}
|
|
151
|
-
out.push('}');
|
|
152
|
-
out.push(`export const ${name}TableIndexMap={`);
|
|
153
|
-
out.push(...indexOut);
|
|
154
|
-
out.push('}');
|
|
155
|
-
}
|
|
156
|
-
importMap[allTableArrayName] = packageName;
|
|
157
|
-
out.push(`export const ${allTableArrayName}=[${tableNames.join(',')}] as const`);
|
|
158
|
-
out.push(`Object.freeze(${allTableArrayName})`);
|
|
159
|
-
if (imports.length) {
|
|
160
|
-
(0, protogen_1.protoPrependTsImports)(imports, importMap, out, localImportMap);
|
|
47
|
+
generate: (context, _a) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
var { tablePath, tablePackage = 'tables', tableFilename = 'tables.ts', tableIndexFilename = 'tables-index.ts', tableUseParamIds, dataTableDescriptionPackage = '@iyio/common', allTableArrayName = 'allTables', tableCdkConstructClassName = 'Tbls', tableCdkConstructFile = context.libStyle === 'nx' ? `packages/cdk/src/${tableCdkConstructClassName}.ts` : undefined } = _a, tsConfig = tslib_1.__rest(_a, ["tablePath", "tablePackage", "tableFilename", "tableIndexFilename", "tableUseParamIds", "dataTableDescriptionPackage", "allTableArrayName", "tableCdkConstructClassName", "tableCdkConstructFile"]);
|
|
49
|
+
const result = yield (0, protogen_table_generator_1.generateProtoTable)(context, Object.assign({ pluginName: 'tablePlugin', supportedTypes: ['table'], tablePath,
|
|
50
|
+
tablePackage,
|
|
51
|
+
tableFilename,
|
|
52
|
+
tableIndexFilename,
|
|
53
|
+
tableUseParamIds,
|
|
54
|
+
dataTableDescriptionPackage,
|
|
55
|
+
allTableArrayName }, tsConfig));
|
|
56
|
+
if (!result) {
|
|
57
|
+
return;
|
|
161
58
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
outputs.push({
|
|
165
|
-
path: (0, common_1.joinPaths)(path, tableFilename),
|
|
166
|
-
content: out.join('\n'),
|
|
167
|
-
});
|
|
168
|
-
outputs.push({
|
|
169
|
-
path: (0, common_1.joinPaths)(path, tableIndexFilename),
|
|
170
|
-
content: '',
|
|
171
|
-
isPackageIndex: true,
|
|
172
|
-
generator: {
|
|
173
|
-
root: path,
|
|
174
|
-
generator: protogen_1.protoGenerateTsIndex
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
if (tableCdkConstructFile) {
|
|
178
|
-
outputs.push({
|
|
59
|
+
if (tableCdkConstructFile && tableCdkConstructClassName) {
|
|
60
|
+
context.outputs.push({
|
|
179
61
|
path: tableCdkConstructFile,
|
|
180
|
-
content: (0, tableCdkTemplate_1.tableCdkTemplate)(tableCdkConstructClassName, tableInfos, importMap)
|
|
62
|
+
content: (0, tableCdkTemplate_1.tableCdkTemplate)(tableCdkConstructClassName, result.tableInfos, context.importMap)
|
|
181
63
|
});
|
|
182
64
|
}
|
|
183
65
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tablePlugin.js","sourceRoot":"","sources":["../../../../../../packages/protogen-runtime/src/lib/plugins/tablePlugin.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"tablePlugin.js","sourceRoot":"","sources":["../../../../../../packages/protogen-runtime/src/lib/plugins/tablePlugin.ts"],"names":[],"mappings":";;;;AACA,6BAAwB;AACxB,0EAAiE;AACjE,sDAA+D;AAC/D,yDAAsD;AAEtD,MAAM,iBAAiB,GAAC,OAAC,CAAC,MAAM,CAChC;IACI,SAAS,EAAC,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAE/B;;OAEG;IACH,aAAa,EAAC,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAEnC;;OAEG;IACH,kBAAkB,EAAC,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAGxC;;OAEG;IACH,YAAY,EAAC,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;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O,CAAC,IAAI,CAAC;gBACjB,IAAI,EAAC,qBAAqB;gBAC1B,OAAO,EAAC,IAAA,mCAAgB,EAAC,0BAA0B,EAAC,MAAM,CAAC,UAAU,EAAC,OAAO,CAAC,SAAS,CAAC;aAC3F,CAAC,CAAA;SACL;IACL,CAAC,CAAA;CACJ,CAAA"}
|
|
@@ -41,7 +41,7 @@ exports.tsProtoNodePlugin = {
|
|
|
41
41
|
path: (0, common_1.joinPaths)(path, tsProtoNodeFilename),
|
|
42
42
|
content: `import { ProtoAddressMap } from '@iyio/protogen';
|
|
43
43
|
|
|
44
|
-
export const ${tsProtoNodeExportName}=${JSON.stringify((0, protogen_1.protoCreateNodeAddressMap)((0, protogen_1.protoRemoveDisplayChildren)((0, common_1.deepClone)(nodes))), null, tsProtoNodeMinify ? 0 : tab.length)} satisfies ProtoAddressMap;`,
|
|
44
|
+
export const ${tsProtoNodeExportName}=${JSON.stringify((0, protogen_1.protoCreateNodeAddressMap)((0, protogen_1.protoRemoveDisplayChildren)((0, common_1.deepClone)(nodes, 1000))), null, tsProtoNodeMinify ? 0 : tab.length)} satisfies ProtoAddressMap;`,
|
|
45
45
|
});
|
|
46
46
|
outputs.push({
|
|
47
47
|
path: (0, common_1.joinPaths)(path, tsProtoNodeIndexFilename),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsProtoNodePlugin.js","sourceRoot":"","sources":["../../../../../../packages/protogen-runtime/src/lib/plugins/tsProtoNodePlugin.ts"],"names":[],"mappings":";;;;AAAA,yCAAoD;AACpD,6CAAyK;AACzK,6BAAwB;AAExB,MAAM,uBAAuB,GAAC,OAAC,CAAC,MAAM,CACtC;IACI;;OAEG;IACH,eAAe,EAAC,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAErC;;OAEG;IACH,kBAAkB,EAAC,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAExC;;OAEG;IACH,mBAAmB,EAAC,OAAC,CAAC,MAAM,EA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