postgresdk 0.18.1 → 0.18.3

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.
Files changed (87) hide show
  1. package/dist/cache.d.ts +1 -0
  2. package/dist/cli.js +12 -7
  3. package/dist/index.js +7 -2
  4. package/package.json +1 -1
  5. package/dist/cli.d.ts.map +0 -1
  6. package/dist/cli.js.map +0 -1
  7. package/dist/core/operations.d.ts +0 -68
  8. package/dist/emit-api-contract.d.ts +0 -60
  9. package/dist/emit-client.d.ts.map +0 -1
  10. package/dist/emit-client.js +0 -114
  11. package/dist/emit-client.js.map +0 -1
  12. package/dist/emit-include-builder.d.ts.map +0 -1
  13. package/dist/emit-include-builder.js +0 -30
  14. package/dist/emit-include-builder.js.map +0 -1
  15. package/dist/emit-include-loader.d.ts.map +0 -1
  16. package/dist/emit-include-loader.js +0 -299
  17. package/dist/emit-include-loader.js.map +0 -1
  18. package/dist/emit-include-spec.d.ts.map +0 -1
  19. package/dist/emit-include-spec.js +0 -26
  20. package/dist/emit-include-spec.js.map +0 -1
  21. package/dist/emit-logger.d.ts.map +0 -1
  22. package/dist/emit-logger.js +0 -35
  23. package/dist/emit-logger.js.map +0 -1
  24. package/dist/emit-router.d.ts +0 -5
  25. package/dist/emit-routes.d.ts.map +0 -1
  26. package/dist/emit-routes.js +0 -208
  27. package/dist/emit-routes.js.map +0 -1
  28. package/dist/emit-server-index.d.ts +0 -5
  29. package/dist/emit-types.d.ts.map +0 -1
  30. package/dist/emit-types.js +0 -51
  31. package/dist/emit-types.js.map +0 -1
  32. package/dist/emit-zod.d.ts.map +0 -1
  33. package/dist/emit-zod.js +0 -43
  34. package/dist/emit-zod.js.map +0 -1
  35. package/dist/gen.config.d.ts +0 -10
  36. package/dist/gen.config.js +0 -10
  37. package/dist/gen.config.js.map +0 -1
  38. package/dist/index.d.ts.map +0 -1
  39. package/dist/index.js.map +0 -1
  40. package/dist/introspect.d.ts.map +0 -1
  41. package/dist/introspect.js +0 -132
  42. package/dist/introspect.js.map +0 -1
  43. package/dist/rel-classify.d.ts.map +0 -1
  44. package/dist/rel-classify.js +0 -52
  45. package/dist/rel-classify.js.map +0 -1
  46. package/dist/src/cli.d.ts +0 -2
  47. package/dist/src/cli.js +0 -39
  48. package/dist/src/cli.js.map +0 -1
  49. package/dist/src/emit-client.d.ts +0 -3
  50. package/dist/src/emit-client.js +0 -114
  51. package/dist/src/emit-client.js.map +0 -1
  52. package/dist/src/emit-include-builder.d.ts +0 -2
  53. package/dist/src/emit-include-builder.js +0 -30
  54. package/dist/src/emit-include-builder.js.map +0 -1
  55. package/dist/src/emit-include-loader.d.ts +0 -9
  56. package/dist/src/emit-include-loader.js +0 -299
  57. package/dist/src/emit-include-loader.js.map +0 -1
  58. package/dist/src/emit-include-spec.d.ts +0 -2
  59. package/dist/src/emit-include-spec.js +0 -26
  60. package/dist/src/emit-include-spec.js.map +0 -1
  61. package/dist/src/emit-logger.d.ts +0 -1
  62. package/dist/src/emit-logger.js +0 -35
  63. package/dist/src/emit-logger.js.map +0 -1
  64. package/dist/src/emit-routes.d.ts +0 -20
  65. package/dist/src/emit-routes.js +0 -208
  66. package/dist/src/emit-routes.js.map +0 -1
  67. package/dist/src/emit-types.d.ts +0 -5
  68. package/dist/src/emit-types.js +0 -51
  69. package/dist/src/emit-types.js.map +0 -1
  70. package/dist/src/emit-zod.d.ts +0 -5
  71. package/dist/src/emit-zod.js +0 -43
  72. package/dist/src/emit-zod.js.map +0 -1
  73. package/dist/src/index.d.ts +0 -1
  74. package/dist/src/index.js +0 -83
  75. package/dist/src/index.js.map +0 -1
  76. package/dist/src/introspect.d.ts +0 -26
  77. package/dist/src/introspect.js +0 -132
  78. package/dist/src/introspect.js.map +0 -1
  79. package/dist/src/rel-classify.d.ts +0 -10
  80. package/dist/src/rel-classify.js +0 -52
  81. package/dist/src/rel-classify.js.map +0 -1
  82. package/dist/src/utils.d.ts +0 -6
  83. package/dist/src/utils.js +0 -17
  84. package/dist/src/utils.js.map +0 -1
  85. package/dist/utils.d.ts.map +0 -1
  86. package/dist/utils.js +0 -17
  87. package/dist/utils.js.map +0 -1
package/dist/cache.d.ts CHANGED
@@ -14,6 +14,7 @@ export interface CacheData {
14
14
  }
15
15
  /**
16
16
  * Compute a deterministic hash of the schema and config
17
+ * Includes postgresdk version to trigger regeneration on upgrades
17
18
  */
18
19
  export declare function computeSchemaHash(model: Model, config: Config): string;
19
20
  /**
package/dist/cli.js CHANGED
@@ -1689,10 +1689,11 @@ var init_emit_sdk_contract = __esm(() => {
1689
1689
  // src/cache.ts
1690
1690
  import { createHash } from "crypto";
1691
1691
  import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2, appendFile } from "fs/promises";
1692
- import { existsSync } from "fs";
1692
+ import { existsSync, readFileSync } from "fs";
1693
1693
  import { join } from "path";
1694
1694
  function computeSchemaHash(model, config) {
1695
1695
  const payload = {
1696
+ version: POSTGRESDK_VERSION,
1696
1697
  schema: model.schema,
1697
1698
  tables: model.tables,
1698
1699
  enums: model.enums,
@@ -1780,7 +1781,11 @@ async function appendToHistory(entry, baseDir) {
1780
1781
  ${formattedEntry}`, "utf-8");
1781
1782
  }
1782
1783
  }
1783
- var init_cache = () => {};
1784
+ var __dirname = "/workspace/src", packageJson, POSTGRESDK_VERSION;
1785
+ var init_cache = __esm(() => {
1786
+ packageJson = JSON.parse(readFileSync(join(__dirname, "../package.json"), "utf-8"));
1787
+ POSTGRESDK_VERSION = packageJson.version;
1788
+ });
1784
1789
 
1785
1790
  // src/cli-config-utils.ts
1786
1791
  function extractConfigFields(configContent) {
@@ -2201,7 +2206,7 @@ var exports_cli_init = {};
2201
2206
  __export(exports_cli_init, {
2202
2207
  initCommand: () => initCommand
2203
2208
  });
2204
- import { existsSync as existsSync3, writeFileSync, readFileSync, copyFileSync } from "fs";
2209
+ import { existsSync as existsSync3, writeFileSync, readFileSync as readFileSync2, copyFileSync } from "fs";
2205
2210
  import { resolve } from "path";
2206
2211
  import prompts from "prompts";
2207
2212
  async function initCommand(args) {
@@ -2219,7 +2224,7 @@ async function initCommand(args) {
2219
2224
  }
2220
2225
  console.log(`⚠️ Found existing postgresdk.config.ts
2221
2226
  `);
2222
- const existingContent = readFileSync(configPath, "utf-8");
2227
+ const existingContent = readFileSync2(configPath, "utf-8");
2223
2228
  const existingFields = extractConfigFields(existingContent);
2224
2229
  console.log("\uD83D\uDCCB Existing configuration detected:");
2225
2230
  existingFields.forEach((field) => {
@@ -7192,13 +7197,13 @@ async function generate(configPath) {
7192
7197
  // src/cli.ts
7193
7198
  var import_config2 = __toESM(require_config(), 1);
7194
7199
  import { resolve as resolve3 } from "node:path";
7195
- import { readFileSync as readFileSync2 } from "node:fs";
7200
+ import { readFileSync as readFileSync3 } from "node:fs";
7196
7201
  import { fileURLToPath } from "node:url";
7197
7202
  import { dirname as dirname4, join as join4 } from "node:path";
7198
7203
  var __filename2 = fileURLToPath(import.meta.url);
7199
7204
  var __dirname2 = dirname4(__filename2);
7200
- var packageJson = JSON.parse(readFileSync2(join4(__dirname2, "../package.json"), "utf-8"));
7201
- var VERSION = packageJson.version;
7205
+ var packageJson2 = JSON.parse(readFileSync3(join4(__dirname2, "../package.json"), "utf-8"));
7206
+ var VERSION = packageJson2.version;
7202
7207
  var args = process.argv.slice(2);
7203
7208
  var command = args[0];
7204
7209
  if (args.includes("--version") || args.includes("-v") || command === "version") {
package/dist/index.js CHANGED
@@ -1688,10 +1688,11 @@ var init_emit_sdk_contract = __esm(() => {
1688
1688
  // src/cache.ts
1689
1689
  import { createHash } from "crypto";
1690
1690
  import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2, appendFile } from "fs/promises";
1691
- import { existsSync } from "fs";
1691
+ import { existsSync, readFileSync } from "fs";
1692
1692
  import { join } from "path";
1693
1693
  function computeSchemaHash(model, config) {
1694
1694
  const payload = {
1695
+ version: POSTGRESDK_VERSION,
1695
1696
  schema: model.schema,
1696
1697
  tables: model.tables,
1697
1698
  enums: model.enums,
@@ -1779,7 +1780,11 @@ async function appendToHistory(entry, baseDir) {
1779
1780
  ${formattedEntry}`, "utf-8");
1780
1781
  }
1781
1782
  }
1782
- var init_cache = () => {};
1783
+ var __dirname = "/workspace/src", packageJson, POSTGRESDK_VERSION;
1784
+ var init_cache = __esm(() => {
1785
+ packageJson = JSON.parse(readFileSync(join(__dirname, "../package.json"), "utf-8"));
1786
+ POSTGRESDK_VERSION = packageJson.version;
1787
+ });
1783
1788
 
1784
1789
  // src/index.ts
1785
1790
  var import_config = __toESM(require_config(), 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postgresdk",
3
- "version": "0.18.1",
3
+ "version": "0.18.3",
4
4
  "description": "Generate a typed server/client SDK from a Postgres schema (includes, Zod, Hono).",
5
5
  "type": "module",
6
6
  "bin": {
package/dist/cli.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,2BAA2B;AAC3B,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACtC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,EAAE,OAAO,CAAC,C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AAClB,CAAC"}
@@ -1,68 +0,0 @@
1
- /**
2
- * Core database operations that are framework-agnostic.
3
- * These functions handle the actual database logic and can be used by any framework adapter.
4
- */
5
- export interface DatabaseClient {
6
- query: (text: string, params?: any[]) => Promise<{
7
- rows: any[];
8
- }>;
9
- }
10
- export interface OperationContext {
11
- pg: DatabaseClient;
12
- table: string;
13
- pkColumns: string[];
14
- softDeleteColumn?: string | null;
15
- includeMethodsDepth: number;
16
- }
17
- /**
18
- * CREATE operation - Insert a new record
19
- */
20
- export declare function createRecord(ctx: OperationContext, data: Record<string, any>): Promise<{
21
- data?: any;
22
- error?: string;
23
- issues?: any;
24
- status: number;
25
- }>;
26
- /**
27
- * READ operation - Get a record by primary key
28
- */
29
- export declare function getByPk(ctx: OperationContext, pkValues: any[]): Promise<{
30
- data?: any;
31
- error?: string;
32
- status: number;
33
- }>;
34
- /**
35
- * LIST operation - Get multiple records with optional filters
36
- */
37
- export declare function listRecords(ctx: OperationContext, params: {
38
- where?: any;
39
- limit?: number;
40
- offset?: number;
41
- include?: any;
42
- orderBy?: string | string[];
43
- order?: "asc" | "desc" | ("asc" | "desc")[];
44
- }): Promise<{
45
- data?: any;
46
- error?: string;
47
- issues?: any;
48
- needsIncludes?: boolean;
49
- includeSpec?: any;
50
- status: number;
51
- }>;
52
- /**
53
- * UPDATE operation - Update a record by primary key
54
- */
55
- export declare function updateRecord(ctx: OperationContext, pkValues: any[], updateData: Record<string, any>): Promise<{
56
- data?: any;
57
- error?: string;
58
- issues?: any;
59
- status: number;
60
- }>;
61
- /**
62
- * DELETE operation - Delete or soft-delete a record by primary key
63
- */
64
- export declare function deleteRecord(ctx: OperationContext, pkValues: any[]): Promise<{
65
- data?: any;
66
- error?: string;
67
- status: number;
68
- }>;
@@ -1,60 +0,0 @@
1
- import type { Model } from "./introspect";
2
- import type { Config, AuthConfig } from "./types";
3
- export interface ApiContract {
4
- version: string;
5
- generatedAt: string;
6
- description: string;
7
- authentication?: {
8
- type: string;
9
- description: string;
10
- };
11
- resources: ResourceContract[];
12
- relationships: RelationshipContract[];
13
- }
14
- export interface ResourceContract {
15
- name: string;
16
- tableName: string;
17
- description: string;
18
- endpoints: EndpointContract[];
19
- fields: FieldContract[];
20
- }
21
- export interface EndpointContract {
22
- method: string;
23
- path: string;
24
- description: string;
25
- requestBody?: any;
26
- responseBody?: any;
27
- queryParameters?: any;
28
- }
29
- export interface FieldContract {
30
- name: string;
31
- type: string;
32
- required: boolean;
33
- description: string;
34
- foreignKey?: {
35
- table: string;
36
- field: string;
37
- };
38
- }
39
- export interface RelationshipContract {
40
- from: string;
41
- to: string;
42
- type: "one-to-many" | "many-to-one" | "many-to-many";
43
- description: string;
44
- }
45
- /**
46
- * Generate a comprehensive API contract in JSON format
47
- */
48
- export declare function generateApiContract(model: Model, config: Config & {
49
- auth?: AuthConfig;
50
- }): ApiContract;
51
- /**
52
- * Generate a human-readable markdown version of the contract
53
- */
54
- export declare function generateApiContractMarkdown(contract: ApiContract): string;
55
- /**
56
- * Emit the API contract as TypeScript code that can be served as an endpoint
57
- */
58
- export declare function emitApiContract(model: Model, config: Config & {
59
- auth?: AuthConfig;
60
- }): string;
@@ -1 +0,0 @@
1
- {"version":3,"file":"emit-client.d.ts","sourceRoot":"","sources":["../src/emit-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1C,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,UA8FtC;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,UAmB9C"}
@@ -1,114 +0,0 @@
1
- import { pascal } from "./utils";
2
- export function emitClient(table) {
3
- const Type = pascal(table.name);
4
- // Normalize PKs
5
- const pkCols = Array.isArray(table.pk)
6
- ? table.pk
7
- : table.pk
8
- ? [table.pk]
9
- : [];
10
- const safePk = pkCols.length ? pkCols : ["id"];
11
- const hasCompositePk = safePk.length > 1;
12
- const pkType = hasCompositePk ? `{ ${safePk.map((c) => `${c}: string`).join("; ")} }` : `string`;
13
- const pkPathExpr = hasCompositePk ? safePk.map((c) => `pk.${c}`).join(` + "/" + `) : `pk`;
14
- return `/* Generated. Do not edit. */
15
- import type { ${Type}IncludeSpec } from "./include-spec";
16
- import type { Insert${Type}, Update${Type}, Select${Type} } from "./types/${table.name}";
17
-
18
- export class ${Type}Client {
19
- constructor(
20
- private baseUrl: string,
21
- private fetchFn: typeof fetch = fetch,
22
- private auth?: () => Promise<Record<string,string>>
23
- ) {}
24
-
25
- private async headers(json = false) {
26
- const extra = (await this.auth?.()) ?? {};
27
- return json ? { "Content-Type": "application/json", ...extra } : extra;
28
- }
29
-
30
- private async okOrThrow(res: Response, action: string) {
31
- if (!res.ok) {
32
- let detail = "";
33
- try { detail = await res.text(); } catch {}
34
- throw new Error(\`\${action} ${table.name} failed: \${res.status} \${detail}\`);
35
- }
36
- }
37
-
38
- async create(data: Insert${Type}): Promise<Select${Type}> {
39
- const res = await this.fetchFn(\`\${this.baseUrl}/v1/${table.name}\`, {
40
- method: "POST",
41
- headers: await this.headers(true),
42
- body: JSON.stringify(data),
43
- });
44
- await this.okOrThrow(res, "create");
45
- return (await res.json()) as Select${Type};
46
- }
47
-
48
- async getByPk(pk: ${pkType}): Promise<Select${Type} | null> {
49
- const path = ${pkPathExpr};
50
- const res = await this.fetchFn(\`\${this.baseUrl}/v1/${table.name}/\${path}\`, {
51
- headers: await this.headers(),
52
- });
53
- if (res.status === 404) return null;
54
- await this.okOrThrow(res, "get");
55
- return (await res.json()) as Select${Type};
56
- }
57
-
58
- async list(params?: { include?: ${Type}IncludeSpec; limit?: number; offset?: number }): Promise<Select${Type}[]> {
59
- const res = await this.fetchFn(\`\${this.baseUrl}/v1/${table.name}/list\`, {
60
- method: "POST",
61
- headers: await this.headers(true),
62
- body: JSON.stringify(params ?? {}),
63
- });
64
- await this.okOrThrow(res, "list");
65
- return (await res.json()) as Select${Type}[];
66
- }
67
-
68
- async update(pk: ${pkType}, patch: Update${Type}): Promise<Select${Type} | null> {
69
- const path = ${pkPathExpr};
70
- const res = await this.fetchFn(\`\${this.baseUrl}/v1/${table.name}/\${path}\`, {
71
- method: "PATCH",
72
- headers: await this.headers(true),
73
- body: JSON.stringify(patch),
74
- });
75
- if (res.status === 404) return null;
76
- await this.okOrThrow(res, "update");
77
- return (await res.json()) as Select${Type};
78
- }
79
-
80
- async delete(pk: ${pkType}): Promise<Select${Type} | null> {
81
- const path = ${pkPathExpr};
82
- const res = await this.fetchFn(\`\${this.baseUrl}/v1/${table.name}/\${path}\`, {
83
- method: "DELETE",
84
- headers: await this.headers(),
85
- });
86
- if (res.status === 404) return null;
87
- await this.okOrThrow(res, "delete");
88
- return (await res.json()) as Select${Type};
89
- }
90
- }
91
- `;
92
- }
93
- export function emitClientIndex(tables) {
94
- let out = `/* Generated. Do not edit. */\n`;
95
- for (const t of tables) {
96
- out += `import { ${pascal(t.name)}Client } from "./${t.name}";\n`;
97
- }
98
- out += `\nexport class SDK {\n`;
99
- for (const t of tables) {
100
- out += ` public ${t.name}: ${pascal(t.name)}Client;\n`;
101
- }
102
- out += `\n constructor(cfg: { baseUrl: string; fetch?: typeof fetch; auth?: () => Promise<Record<string,string>> }) {\n`;
103
- out += ` const f = cfg.fetch ?? fetch;\n`;
104
- for (const t of tables) {
105
- out += ` this.${t.name} = new ${pascal(t.name)}Client(cfg.baseUrl, f, cfg.auth);\n`;
106
- }
107
- out += ` }\n`;
108
- out += `}\n`;
109
- for (const t of tables)
110
- out += `export { ${pascal(t.name)}Client } from "./${t.name}";\n`;
111
- out += `export * from "./include-spec";\n`;
112
- return out;
113
- }
114
- //# sourceMappingURL=emit-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"emit-client.js","sourceRoot":"","sources":["../src/emit-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,MAAM,UAAU,UAAU,CAAC,KAAY;IACrC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,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E,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,UA4BhE"}
@@ -1,30 +0,0 @@
1
- export function emitIncludeBuilder(graph, maxDepth) {
2
- return `// Generated. Do not edit.
3
- export const RELATION_GRAPH = ${JSON.stringify(graph, null, 2)} as const;
4
- type TableName = keyof typeof RELATION_GRAPH;
5
-
6
- export function buildWith(root: TableName, spec: any, maxDepth = ${maxDepth}) {
7
- return walk(root as string, spec, 0);
8
- function walk(table: string, s: any, depth: number): any {
9
- if (!s || depth >= maxDepth) return undefined;
10
- const rels: any = (RELATION_GRAPH as any)[table] || {};
11
- const out: any = {};
12
- for (const key of Object.keys(s)) {
13
- const rel = rels[key];
14
- if (!rel) throw new Error(\`Unknown include key '\${key}' on table '\${table}'\`);
15
- const v = s[key];
16
- if (v === true) out[key] = true;
17
- else if (v && typeof v === "object") {
18
- const child = "include" in v ? walk(rel.target, v.include, depth + 1) : undefined;
19
- out[key] = child ? { with: child } : true;
20
- }
21
- }
22
- return Object.keys(out).length ? out : undefined;
23
- }
24
- }
25
-
26
- export const buildWithFor = (t: TableName) =>
27
- (spec?: any, depth = ${maxDepth}) => (spec ? buildWith(t, spec, depth) : undefined);
28
- `;
29
- }
30
- //# sourceMappingURL=emit-include-builder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"emit-include-builder.js","sourceRoot":"","sources":["../src/emit-include-builder.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,kBAAkB,CAAC,KAAY,EAAE,QAAgB;IAC/D,OAAO;gCACuB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;;;mEAGK,QAAQ;;;;;;;;;;;;;;;;;;;;;yBAqBlD,QAAQ;CAChC,CAAC;AACF,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"emit-include-loader.d.ts","sourceRoot":"","sources":["../src/emit-include-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,UAgT7E"}