@google-cloud/kcmd 0.0.0-stage → 0.2.0

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 (150) hide show
  1. package/LICENSE +203 -0
  2. package/README.md +264 -2
  3. package/build/ts/kcmd/cli.js +20252 -0
  4. package/build/ts/kcmd/gcp/alloydb.d.ts +12 -0
  5. package/build/ts/kcmd/gcp/alloydb.js +70 -0
  6. package/build/ts/kcmd/gcp/api.d.ts +29 -0
  7. package/build/ts/kcmd/gcp/api.js +162 -0
  8. package/build/ts/kcmd/gcp/biglake.d.ts +18 -0
  9. package/build/ts/kcmd/gcp/biglake.js +59 -0
  10. package/build/ts/kcmd/gcp/bigquery.d.ts +57 -0
  11. package/build/ts/kcmd/gcp/bigquery.js +134 -0
  12. package/build/ts/kcmd/gcp/context.d.ts +10 -0
  13. package/build/ts/kcmd/gcp/context.js +74 -0
  14. package/build/ts/kcmd/gcp/crm.d.ts +13 -0
  15. package/build/ts/kcmd/gcp/crm.js +91 -0
  16. package/build/ts/kcmd/gcp/dataplex.d.ts +147 -0
  17. package/build/ts/kcmd/gcp/dataplex.js +406 -0
  18. package/build/ts/kcmd/gcp/index.d.ts +3 -0
  19. package/build/ts/kcmd/gcp/index.js +21 -0
  20. package/build/ts/kcmd/gcp/spanner.d.ts +73 -0
  21. package/build/ts/kcmd/gcp/spanner.js +126 -0
  22. package/build/ts/kcmd/index.d.ts +7 -0
  23. package/build/ts/kcmd/index.js +46 -0
  24. package/build/ts/kcmd/layout.d.ts +16 -0
  25. package/build/ts/kcmd/layout.js +31 -0
  26. package/build/ts/kcmd/layouts/documents.d.ts +24 -0
  27. package/build/ts/kcmd/layouts/documents.js +264 -0
  28. package/build/ts/kcmd/layouts/okf.d.ts +31 -0
  29. package/build/ts/kcmd/layouts/okf.js +386 -0
  30. package/build/ts/kcmd/layouts/semantic-model.d.ts +74 -0
  31. package/build/ts/kcmd/layouts/semantic-model.js +621 -0
  32. package/build/ts/kcmd/layouts/standard.d.ts +13 -0
  33. package/build/ts/kcmd/layouts/standard.js +108 -0
  34. package/build/ts/kcmd/manifest.d.ts +34 -0
  35. package/build/ts/kcmd/manifest.js +262 -0
  36. package/build/ts/kcmd/metadata.d.ts +25 -0
  37. package/build/ts/kcmd/metadata.js +8 -0
  38. package/build/ts/kcmd/okf/catalog_residue.d.ts +14 -0
  39. package/build/ts/kcmd/okf/catalog_residue.js +124 -0
  40. package/build/ts/kcmd/okf/concept.d.ts +14 -0
  41. package/build/ts/kcmd/okf/concept.js +110 -0
  42. package/build/ts/kcmd/okf/concept_to_entry.d.ts +10 -0
  43. package/build/ts/kcmd/okf/concept_to_entry.js +281 -0
  44. package/build/ts/kcmd/okf/init_okf_workspace.d.ts +15 -0
  45. package/build/ts/kcmd/okf/init_okf_workspace.js +113 -0
  46. package/build/ts/kcmd/okf/links.d.ts +23 -0
  47. package/build/ts/kcmd/okf/links.js +468 -0
  48. package/build/ts/kcmd/okf/okf_metadata.d.ts +12 -0
  49. package/build/ts/kcmd/okf/okf_metadata.js +99 -0
  50. package/build/ts/kcmd/semantic/bigquery.d.ts +22 -0
  51. package/build/ts/kcmd/semantic/bigquery.js +469 -0
  52. package/build/ts/kcmd/semantic/binding.d.ts +3 -0
  53. package/build/ts/kcmd/semantic/binding.js +92 -0
  54. package/build/ts/kcmd/semantic/catalog_entry.d.ts +24 -0
  55. package/build/ts/kcmd/semantic/catalog_entry.js +35 -0
  56. package/build/ts/kcmd/semantic/converters/owl/convert.d.ts +26 -0
  57. package/build/ts/kcmd/semantic/converters/owl/convert.js +41 -0
  58. package/build/ts/kcmd/semantic/converters/owl/model.d.ts +98 -0
  59. package/build/ts/kcmd/semantic/converters/owl/model.js +30 -0
  60. package/build/ts/kcmd/semantic/converters/owl/parse.d.ts +11 -0
  61. package/build/ts/kcmd/semantic/converters/owl/parse.js +634 -0
  62. package/build/ts/kcmd/semantic/converters/owl/to_ir.d.ts +19 -0
  63. package/build/ts/kcmd/semantic/converters/owl/to_ir.js +390 -0
  64. package/build/ts/kcmd/semantic/deploy_bigquery.d.ts +20 -0
  65. package/build/ts/kcmd/semantic/deploy_bigquery.js +226 -0
  66. package/build/ts/kcmd/semantic/deploy_knowledge_catalog.d.ts +104 -0
  67. package/build/ts/kcmd/semantic/deploy_knowledge_catalog.js +1367 -0
  68. package/build/ts/kcmd/semantic/deploy_spanner.d.ts +15 -0
  69. package/build/ts/kcmd/semantic/deploy_spanner.js +150 -0
  70. package/build/ts/kcmd/semantic/deployment_target.d.ts +93 -0
  71. package/build/ts/kcmd/semantic/deployment_target.js +379 -0
  72. package/build/ts/kcmd/semantic/graph_ddl.d.ts +44 -0
  73. package/build/ts/kcmd/semantic/graph_ddl.js +656 -0
  74. package/build/ts/kcmd/semantic/import_model.d.ts +72 -0
  75. package/build/ts/kcmd/semantic/import_model.js +1698 -0
  76. package/build/ts/kcmd/semantic/ir.d.ts +589 -0
  77. package/build/ts/kcmd/semantic/ir.js +247 -0
  78. package/build/ts/kcmd/semantic/kc_actions.d.ts +45 -0
  79. package/build/ts/kcmd/semantic/kc_actions.js +531 -0
  80. package/build/ts/kcmd/semantic/kc_constraints.d.ts +44 -0
  81. package/build/ts/kcmd/semantic/kc_constraints.js +279 -0
  82. package/build/ts/kcmd/semantic/kc_converter.d.ts +37 -0
  83. package/build/ts/kcmd/semantic/kc_converter.js +839 -0
  84. package/build/ts/kcmd/semantic/kc_custom_types.d.ts +63 -0
  85. package/build/ts/kcmd/semantic/kc_custom_types.js +751 -0
  86. package/build/ts/kcmd/semantic/kc_entries.d.ts +155 -0
  87. package/build/ts/kcmd/semantic/kc_entries.js +284 -0
  88. package/build/ts/kcmd/semantic/kc_ids.d.ts +102 -0
  89. package/build/ts/kcmd/semantic/kc_ids.js +188 -0
  90. package/build/ts/kcmd/semantic/knowledge_catalog.d.ts +29 -0
  91. package/build/ts/kcmd/semantic/knowledge_catalog.js +960 -0
  92. package/build/ts/kcmd/semantic/loader.d.ts +258 -0
  93. package/build/ts/kcmd/semantic/loader.js +3576 -0
  94. package/build/ts/kcmd/semantic/names.d.ts +10 -0
  95. package/build/ts/kcmd/semantic/names.js +85 -0
  96. package/build/ts/kcmd/semantic/osi_converter.d.ts +60 -0
  97. package/build/ts/kcmd/semantic/osi_converter.js +910 -0
  98. package/build/ts/kcmd/semantic/parameters.d.ts +19 -0
  99. package/build/ts/kcmd/semantic/parameters.js +171 -0
  100. package/build/ts/kcmd/semantic/pull_kc.d.ts +10 -0
  101. package/build/ts/kcmd/semantic/pull_kc.js +272 -0
  102. package/build/ts/kcmd/semantic/resolve_inheritance.d.ts +59 -0
  103. package/build/ts/kcmd/semantic/resolve_inheritance.js +346 -0
  104. package/build/ts/kcmd/semantic/resolve_profiles.d.ts +291 -0
  105. package/build/ts/kcmd/semantic/resolve_profiles.js +2003 -0
  106. package/build/ts/kcmd/semantic/runtime/agent_tools.d.ts +93 -0
  107. package/build/ts/kcmd/semantic/runtime/agent_tools.js +243 -0
  108. package/build/ts/kcmd/semantic/runtime/dialect.d.ts +13 -0
  109. package/build/ts/kcmd/semantic/runtime/dialect.js +39 -0
  110. package/build/ts/kcmd/semantic/runtime/runtime.d.ts +88 -0
  111. package/build/ts/kcmd/semantic/runtime/runtime.js +301 -0
  112. package/build/ts/kcmd/semantic/runtime/store.d.ts +112 -0
  113. package/build/ts/kcmd/semantic/runtime/store.js +344 -0
  114. package/build/ts/kcmd/semantic/skills.d.ts +110 -0
  115. package/build/ts/kcmd/semantic/skills.js +697 -0
  116. package/build/ts/kcmd/semantic/source_dialect.d.ts +17 -0
  117. package/build/ts/kcmd/semantic/source_dialect.js +311 -0
  118. package/build/ts/kcmd/semantic/source_entries.d.ts +12 -0
  119. package/build/ts/kcmd/semantic/source_entries.js +341 -0
  120. package/build/ts/kcmd/semantic/spanner.d.ts +18 -0
  121. package/build/ts/kcmd/semantic/spanner.js +60 -0
  122. package/build/ts/kcmd/semantic/sql_expr_utils.d.ts +23 -0
  123. package/build/ts/kcmd/semantic/sql_expr_utils.js +394 -0
  124. package/build/ts/kcmd/semantic/sql_identifiers.d.ts +6 -0
  125. package/build/ts/kcmd/semantic/sql_identifiers.js +267 -0
  126. package/build/ts/kcmd/semantic/sql_parser.d.ts +47 -0
  127. package/build/ts/kcmd/semantic/sql_parser.js +400 -0
  128. package/build/ts/kcmd/semantic/transpile.d.ts +76 -0
  129. package/build/ts/kcmd/semantic/transpile.js +581 -0
  130. package/build/ts/kcmd/semantic/validate.d.ts +70 -0
  131. package/build/ts/kcmd/semantic/validate.js +2266 -0
  132. package/build/ts/kcmd/semantic/yaml_options.d.ts +6 -0
  133. package/build/ts/kcmd/semantic/yaml_options.js +58 -0
  134. package/build/ts/kcmd/semantic/yaml_update.d.ts +26 -0
  135. package/build/ts/kcmd/semantic/yaml_update.js +782 -0
  136. package/build/ts/kcmd/snapshot.d.ts +37 -0
  137. package/build/ts/kcmd/snapshot.js +386 -0
  138. package/build/ts/kcmd/source.d.ts +31 -0
  139. package/build/ts/kcmd/source.js +119 -0
  140. package/build/ts/kcmd/sources/bq-dataset.d.ts +17 -0
  141. package/build/ts/kcmd/sources/bq-dataset.js +131 -0
  142. package/build/ts/kcmd/sources/entrygroup.d.ts +21 -0
  143. package/build/ts/kcmd/sources/entrygroup.js +83 -0
  144. package/build/ts/kcmd/sources/kb.d.ts +21 -0
  145. package/build/ts/kcmd/sources/kb.js +82 -0
  146. package/build/ts/kcmd/sources/semantic-model.d.ts +18 -0
  147. package/build/ts/kcmd/sources/semantic-model.js +48 -0
  148. package/build/ts/kcmd/sync.d.ts +35 -0
  149. package/build/ts/kcmd/sync.js +734 -0
  150. package/package.json +62 -4
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ // BigQuery Dataset as Metadata Source
3
+ //
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.BigQueryDatasetSource = void 0;
39
+ const gcp = __importStar(require("../gcp"));
40
+ const bq = __importStar(require("../gcp/bigquery"));
41
+ const layout_1 = require("../layout");
42
+ const md = __importStar(require("../metadata"));
43
+ class BigQueryDatasetSource {
44
+ type;
45
+ name;
46
+ ingestedEntries = true;
47
+ layout = layout_1.Layouts.STANDARD;
48
+ defaultAspects = [md.OVERVIEW_ASPECT];
49
+ // BigQuery and Dataplex data scans write these on a table besides the ones
50
+ // its type requires.
51
+ systemAspects = [
52
+ 'dataplex-types.global.bigquery-policy',
53
+ 'dataplex-types.global.data-profile',
54
+ 'dataplex-types.global.data-quality-scorecard',
55
+ 'dataplex-types.global.usage',
56
+ ];
57
+ _datasets;
58
+ constructor(type, name, datasets) {
59
+ this.type = type;
60
+ this.name = name;
61
+ this._datasets = datasets;
62
+ }
63
+ async *entries(ctx) {
64
+ const bigQuery = new bq.BigQueryClient(ctx);
65
+ const catalog = new gcp.CatalogClient(ctx);
66
+ for (const [_, dsResource] of this._datasets.entries()) {
67
+ const project = dsResource.datasetReference.projectId;
68
+ const dataset = dsResource.datasetReference.datasetId;
69
+ // Fetch the dataset entry
70
+ const location = dsResource.location.toLowerCase();
71
+ const dsEntryId = `bigquery.googleapis.com/projects/${project}/datasets/${dataset}`;
72
+ const dsEntryName = `${gcp.catalogContainer(project, location, '@bigquery')}/entries/${dsEntryId}`;
73
+ const dsEntryResult = await catalog.lookupEntry(project, location, dsEntryName);
74
+ if (!dsEntryResult.result) {
75
+ throw new Error(`Failed to get Entry for dataset ${project}.${dataset}`);
76
+ }
77
+ yield dsEntryResult.result;
78
+ // Fetch the table entries
79
+ for await (const table of bigQuery.listTables(project, dataset)) {
80
+ const tableId = table.tableReference.tableId;
81
+ const tableEntryName = `${dsEntryName}/tables/${tableId}`;
82
+ const tableEntryResult = await catalog.lookupEntry(project, location, tableEntryName);
83
+ if (!tableEntryResult.result) {
84
+ throw new Error(`Failed to get Entry for table ${project}.${dataset}.${tableId}`);
85
+ }
86
+ yield tableEntryResult.result;
87
+ }
88
+ }
89
+ // TODO: Add support for routines, models
90
+ }
91
+ localName(entry) {
92
+ // The local catalog uses simplified path scheme:
93
+ // dataset -> <project id>.<dataset id>
94
+ // table -> <project id>.<dataset id>/<table id>
95
+ // model -> <project id>.<dataset id>/models/<model id>
96
+ // routine -> <project id>.<dataset id>/routines/<routine id>
97
+ let match = entry.name.match(/\/projects\/([^/]+)\/datasets\/([^/]+)\/(tables|models|routines)\/(.+)$/);
98
+ if (match) {
99
+ const [, project, dataset, type, id] = match;
100
+ if (type === 'tables') {
101
+ return `${project}.${dataset}/${id}`;
102
+ }
103
+ return `${type}/${project}.${dataset}/${id}`;
104
+ }
105
+ match = entry.name.match(/\/projects\/([^/]+)\/datasets\/([^/]+)$/);
106
+ if (match) {
107
+ const [, project, dataset] = match;
108
+ return `${project}.${dataset}`;
109
+ }
110
+ throw new Error(`Invalid BigQuery entry: ${entry.name}`);
111
+ }
112
+ serviceName(localName) {
113
+ const nameParts = localName.split('/');
114
+ const dsResource = this._datasets.get(nameParts[0]);
115
+ if (!dsResource) {
116
+ throw new Error(`Failed to find dataset for ${nameParts[0]}`);
117
+ }
118
+ const project = dsResource.datasetReference.projectId;
119
+ const location = dsResource.location.toLowerCase();
120
+ const dataset = dsResource.datasetReference.datasetId;
121
+ const entryGroup = `${gcp.catalogContainer(project, location, '@bigquery')}`;
122
+ const entryName = `${entryGroup}/entries/bigquery.googleapis.com/projects/${project}/datasets/${dataset}`;
123
+ if (nameParts.length == 1) {
124
+ return entryName;
125
+ }
126
+ const collection = nameParts.length == 2 ? 'tables' : nameParts[1];
127
+ const resource = nameParts.length == 2 ? nameParts[1] : nameParts[2];
128
+ return `${entryName}/${collection}/${resource}`;
129
+ }
130
+ }
131
+ exports.BigQueryDatasetSource = BigQueryDatasetSource;
@@ -0,0 +1,21 @@
1
+ import * as gcp from '../gcp';
2
+ import * as dataplex from '../gcp/dataplex';
3
+ import { Layouts } from '../layout';
4
+ import { CatalogSource } from '../source';
5
+ export declare class EntryGroupSource implements CatalogSource {
6
+ readonly type: string;
7
+ readonly name: string;
8
+ readonly ingestedEntries: boolean;
9
+ readonly layout = Layouts.STANDARD;
10
+ readonly defaultAspects: string[];
11
+ readonly systemAspects: never[];
12
+ readonly project: string;
13
+ readonly location: string;
14
+ readonly entryGroup: string;
15
+ private readonly _name;
16
+ private readonly _entryGroup;
17
+ constructor(type: string, name: string, entryGroup: dataplex.EntryGroup);
18
+ entries(ctx: gcp.ApiContext): AsyncGenerator<gcp.Entry, void, unknown>;
19
+ localName(entry: gcp.Entry): string;
20
+ serviceName(localName: string): string;
21
+ }
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ // Dataplex EntryGroup as Metadata Source
3
+ //
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.EntryGroupSource = void 0;
39
+ const gcp = __importStar(require("../gcp"));
40
+ const layout_1 = require("../layout");
41
+ const md = __importStar(require("../metadata"));
42
+ class EntryGroupSource {
43
+ type;
44
+ name;
45
+ ingestedEntries;
46
+ layout = layout_1.Layouts.STANDARD;
47
+ defaultAspects = [md.OVERVIEW_ASPECT];
48
+ systemAspects = [];
49
+ project;
50
+ location;
51
+ entryGroup;
52
+ _name;
53
+ _entryGroup;
54
+ constructor(type, name, entryGroup) {
55
+ this.type = type;
56
+ this.name = name;
57
+ this._name = name.split('.');
58
+ this.project = this._name[0];
59
+ this.location = this._name[1];
60
+ this.entryGroup = this._name[2];
61
+ this._entryGroup = entryGroup;
62
+ this.ingestedEntries = this._name[2].startsWith('@');
63
+ }
64
+ async *entries(ctx) {
65
+ // Enumerate all entries in the EntryGroup
66
+ const catalog = new gcp.CatalogClient(ctx);
67
+ for await (const entry of catalog.listEntries(this._name[0], this._name[1], this._name[2])) {
68
+ yield entry;
69
+ }
70
+ }
71
+ localName(entry) {
72
+ // The local catalog uses the entry id as is
73
+ const match = entry.name.match(/entryGroups\/([^/]+)\/entries\/(.+)$/);
74
+ if (!match) {
75
+ throw new Error(`Invalid entry name for entry: ${entry.name}`);
76
+ }
77
+ return match[2];
78
+ }
79
+ serviceName(localName) {
80
+ return `${this._entryGroup.name}/entries/${localName}`;
81
+ }
82
+ }
83
+ exports.EntryGroupSource = EntryGroupSource;
@@ -0,0 +1,21 @@
1
+ import * as gcp from '../gcp';
2
+ import * as dataplex from '../gcp/dataplex';
3
+ import { Layouts } from '../layout';
4
+ import { CatalogSource } from '../source';
5
+ export declare class KnowledgeBaseSource implements CatalogSource {
6
+ readonly type: string;
7
+ readonly name: string;
8
+ readonly ingestedEntries = false;
9
+ readonly layout = Layouts.DOCUMENTS;
10
+ readonly defaultAspects: string[];
11
+ readonly systemAspects: never[];
12
+ readonly project: string;
13
+ readonly location: string;
14
+ readonly entryGroup: string;
15
+ private readonly _name;
16
+ private readonly _entryGroup;
17
+ constructor(type: string, name: string, entryGroup: dataplex.EntryGroup);
18
+ entries(ctx: gcp.ApiContext): AsyncGenerator<gcp.Entry, void, unknown>;
19
+ localName(entry: gcp.Entry): string;
20
+ serviceName(localName: string): string;
21
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ // Dataplex Wiki managed as an EntryGroup as Metadata Source
3
+ //
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.KnowledgeBaseSource = void 0;
39
+ const gcp = __importStar(require("../gcp"));
40
+ const layout_1 = require("../layout");
41
+ const md = __importStar(require("../metadata"));
42
+ class KnowledgeBaseSource {
43
+ type;
44
+ name;
45
+ ingestedEntries = false;
46
+ layout = layout_1.Layouts.DOCUMENTS;
47
+ defaultAspects = [md.OVERVIEW_ASPECT];
48
+ systemAspects = [];
49
+ project;
50
+ location;
51
+ entryGroup;
52
+ _name;
53
+ _entryGroup;
54
+ constructor(type, name, entryGroup) {
55
+ this.type = type;
56
+ this.name = name;
57
+ this._name = name.split('.');
58
+ this.project = this._name[0];
59
+ this.location = this._name[1];
60
+ this.entryGroup = this._name[2];
61
+ this._entryGroup = entryGroup;
62
+ }
63
+ async *entries(ctx) {
64
+ // Enumerate all entries in the EntryGroup
65
+ const catalog = new gcp.CatalogClient(ctx);
66
+ for await (const entry of catalog.listEntries(this._name[0], this._name[1], this._name[2])) {
67
+ yield entry;
68
+ }
69
+ }
70
+ localName(entry) {
71
+ // The local catalog uses the entry id as is
72
+ const match = entry.name.match(/entryGroups\/([^/]+)\/entries\/(.+)$/);
73
+ if (!match) {
74
+ throw new Error(`Invalid entry name for entry: ${entry.name}`);
75
+ }
76
+ return match[2];
77
+ }
78
+ serviceName(localName) {
79
+ return `${this._entryGroup.name}/entries/${localName}`;
80
+ }
81
+ }
82
+ exports.KnowledgeBaseSource = KnowledgeBaseSource;
@@ -0,0 +1,18 @@
1
+ import * as gcp from '../gcp';
2
+ import { Layouts } from '../layout';
3
+ import { CatalogSource } from '../source';
4
+ export declare class SemanticModelSource implements CatalogSource {
5
+ readonly type: string;
6
+ readonly name: string;
7
+ readonly ingestedEntries = false;
8
+ readonly layout = Layouts.SEMANTIC_MODEL;
9
+ readonly defaultAspects: never[];
10
+ readonly systemAspects: never[];
11
+ readonly project: string;
12
+ readonly location: string;
13
+ readonly entryGroup: string;
14
+ constructor(type: string, name: string);
15
+ entries(_ctx: gcp.ApiContext): AsyncGenerator<gcp.Entry, void, unknown>;
16
+ localName(_entry: gcp.Entry): string;
17
+ serviceName(_localName: string): string;
18
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ // A locally-authored Semantic Model as a Metadata Source
3
+ //
4
+ // The model is authored on the local filesystem as a single Apache Ossie
5
+ // document per model (the SemanticModel layout); it is not ingested from a
6
+ // remote service. `push` deploys the model's BigQuery Graph.
7
+ //
8
+ // Knowledge Catalog resource emit (entries + entryLinks) for the semantic model
9
+ // is a follow-on; the sync-oriented members below are therefore not yet wired.
10
+ //
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SemanticModelSource = void 0;
13
+ const layout_1 = require("../layout");
14
+ class SemanticModelSource {
15
+ type;
16
+ name;
17
+ ingestedEntries = false;
18
+ layout = layout_1.Layouts.SEMANTIC_MODEL;
19
+ // A semantic model is pulled by its own path, not by snapshot aspects.
20
+ defaultAspects = [];
21
+ systemAspects = [];
22
+ project;
23
+ location;
24
+ entryGroup;
25
+ constructor(type, name) {
26
+ const [project, location, entryGroup] = name.split('.');
27
+ if (!project || !location || !entryGroup) {
28
+ throw new Error('Semantic model scope must be in format <projectId>.<locationId>.<entryGroupId>');
29
+ }
30
+ this.type = type;
31
+ this.name = name;
32
+ this.project = project;
33
+ this.location = location;
34
+ this.entryGroup = entryGroup;
35
+ }
36
+ // The model is authored locally; there is nothing to enumerate from a
37
+ // service.
38
+ async *entries(_ctx) {
39
+ return;
40
+ }
41
+ localName(_entry) {
42
+ throw new Error('Knowledge Catalog resource sync is not supported for the semantic-model scope yet.');
43
+ }
44
+ serviceName(_localName) {
45
+ throw new Error('Knowledge Catalog resource sync is not supported for the semantic-model scope yet.');
46
+ }
47
+ }
48
+ exports.SemanticModelSource = SemanticModelSource;
@@ -0,0 +1,35 @@
1
+ import * as gcp from './gcp';
2
+ import { CatalogSnapshot } from './snapshot';
3
+ export interface SyncResult {
4
+ success: boolean;
5
+ details?: string;
6
+ }
7
+ export interface PullSyncOptions {
8
+ dryRun?: boolean;
9
+ forceRemove?: boolean;
10
+ }
11
+ export interface ValidationResult {
12
+ valid: boolean;
13
+ }
14
+ export interface StatusResult {
15
+ modified: boolean;
16
+ }
17
+ export declare function mapConcurrent<T, R>(items: readonly T[], limit: number, fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
18
+ export declare function isUnimplementedBatch(res: {
19
+ status: number;
20
+ body?: string;
21
+ }): boolean;
22
+ export declare class CatalogSync {
23
+ private _catalog;
24
+ private _snapshot;
25
+ constructor(catalog: gcp.CatalogClient, snapshot: CatalogSnapshot);
26
+ pull(options?: PullSyncOptions): Promise<SyncResult>;
27
+ push(options?: {
28
+ force?: boolean;
29
+ validateOnly?: boolean;
30
+ }): Promise<SyncResult>;
31
+ private _pullOkf;
32
+ private _pushOkf;
33
+ validate(): Promise<ValidationResult>;
34
+ status(): Promise<StatusResult>;
35
+ }