@fraym/crud 0.17.1 → 0.18.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Becklyn Studios
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -15,33 +15,12 @@ There is a sandbox available at `http://crud:3000/delivery/graphql/sandbox`.
15
15
 
16
16
  You need to add the `Tenant-Id` header in order to use the graphQL Endpoint and the sandbox.
17
17
 
18
- ## CLI command
19
-
20
- Use the `crud` cli command to automatically apply your crud schemas to the crud service.
21
-
22
- Your type schemas have to match the glob you specify in the `CRUD_SCHEMA_GLOB` env variable (default: `./src/**/*.graphql`).
23
-
24
- Delivery API: You can specify the address (and port) of the crud service instance you use in the `CRUD_SERVER_ADDRESS` env variable (default: `127.0.0.1:9000`).
25
-
26
- Management API: You can specify the address (and port) of the crud service instance you use in the `CRUD_MANAGEMENT_SERVER_ADDRESS` env variable (default: `http://127.0.0.1`). You will also need to set the `CRUD_MANAGEMENT_API_TOKEN` variable. The value of that token has to match the token configured in the crud service.
27
-
28
- You might have a seperate permissions directory or file. As soon as your permissions schema enum is not part of the projections glob you can specify a `PERMISSIONS_SCHEMA_GLOB` env variable. It is empty by default but as soon as you provide it it will add the files in that glob to your projections schema, too.
29
-
30
- Use the `CRUD_NAMESPACE` env variable to restrict all migrations to your namespace. This is useful if multiple apps share the crud service. Note: You cannot name your crud type or namespace by a `Fraym` prefix. This is a reserved prefix for fraym apps.
31
-
32
- You need to add a file that contains all built-in directives to your type schemas. The latest version of this file can be found [here](default.graphql).
33
-
34
18
  ### Config
35
19
 
36
20
  Use a `.env` file or env variables to configure cte clients and the command:
37
21
 
38
22
  ```env
39
23
  CRUD_SERVER_ADDRESS=127.0.0.1:9000
40
- CRUD_MANAGEMENT_SERVER_ADDRESS=http://127.0.0.1
41
- CRUD_MANAGEMENT_API_TOKEN=
42
- CRUD_SCHEMA_GLOB=./src/crud/*.graphql
43
- PERMISSIONS_SCHEMA_GLOB=
44
- CRUD_NAMESPACE=
45
24
  ```
46
25
 
47
26
  ## Usage
@@ -54,42 +33,6 @@ delivery client:
54
33
  const deliveryClient = await newDeliveryClient();
55
34
  ```
56
35
 
57
- management client:
58
-
59
- ```typescript
60
- const managementClient = await newManagementClient();
61
- ```
62
-
63
- ### Create one or multipe CRUD types
64
-
65
- Crud types are defined by schemas. A schema can contain more than one type definition. See [SCHEMA.md](SCHEMA.md) for a reference.
66
-
67
- ```typescript
68
- await managementClient.createTypes("your schema here");
69
- ```
70
-
71
- ### Update one or multipe CRUD types
72
-
73
- Crud types are defined by schemas. A schema can contain more than one type definition. See [SCHEMA.md](SCHEMA.md) for a reference.
74
-
75
- ```typescript
76
- await managementClient.updateTypes("your schema here");
77
- ```
78
-
79
- ### Remove one or multipe CRUD types
80
-
81
- The name of `YourCrudType` has to equal your type name in your schema (also in casing).
82
-
83
- ```typescript
84
- await managementClient.removeTypes(["YourCrudType"]);
85
- ```
86
-
87
- ### Get list of existing CRUD types
88
-
89
- ```typescript
90
- const list = await managementClient.getAllTypes();
91
- ```
92
-
93
36
  ### Authorization
94
37
 
95
38
  All delivery client functions make use of the `AuthData` object.
@@ -27,7 +27,8 @@ const createCrudData = async (type, authData, data, id, eventMetadata, serviceCl
27
27
  reject(error.message);
28
28
  return;
29
29
  }
30
- if (response.validationErrors || response.fieldValidationErrors) {
30
+ if (response.validationErrors.length > 0 ||
31
+ Object.keys(response.fieldValidationErrors).length > 0) {
31
32
  resolve({
32
33
  validationErrors: response.validationErrors,
33
34
  fieldValidationErrors: response.fieldValidationErrors,
@@ -27,7 +27,8 @@ const updateCrudData = async (type, authData, id, data, eventMetadata, serviceCl
27
27
  reject(error.message);
28
28
  return;
29
29
  }
30
- if (response.validationErrors || response.fieldValidationErrors) {
30
+ if (response.validationErrors.length > 0 ||
31
+ Object.keys(response.fieldValidationErrors).length > 0) {
31
32
  resolve({
32
33
  validationErrors: response.validationErrors,
33
34
  fieldValidationErrors: response.fieldValidationErrors,
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from "./delivery/client";
2
- export * from "./management/client";
3
2
  export { Filter, FieldFilter } from "./delivery/filter";
4
3
  export { Order } from "./delivery/order";
5
4
  export * from "./config/config";
package/dist/index.js CHANGED
@@ -15,5 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./delivery/client"), exports);
18
- __exportStar(require("./management/client"), exports);
19
18
  __exportStar(require("./config/config"), exports);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fraym/crud",
3
- "version": "0.17.1",
4
- "license": "UNLICENSED",
3
+ "version": "0.18.0",
4
+ "license": "MIT",
5
5
  "homepage": "https://github.com/fraym/crud-nodejs",
6
6
  "repository": {
7
7
  "type": "git",
@@ -12,20 +12,16 @@
12
12
  "test": "echo \"Error: no test specified\" && exit 0",
13
13
  "format": "prettier --write \"**/*.{ts,tsx,json}\"",
14
14
  "lint": "prettier --check \"**/*.{ts,tsx,json}\"",
15
- "build": "npm run clean && tsc && chmod +x dist/cmd/crud.js",
15
+ "build": "npm run clean && tsc",
16
16
  "clean": "rm -rf dist",
17
17
  "prepublishOnly": "npm test && npm run lint && npm run build",
18
- "preversion": "npm run lint",
19
- "cmd": "dist/cmd/crud.js"
18
+ "preversion": "npm run lint"
20
19
  },
21
20
  "files": [
22
21
  "dist/**/*"
23
22
  ],
24
23
  "main": "dist/index.js",
25
24
  "types": "dist/index.d.ts",
26
- "bin": {
27
- "crud": "dist/cmd/crud.js"
28
- },
29
25
  "dependencies": {
30
26
  "@fraym/crud-proto": "1.0.0-alpha.17",
31
27
  "@graphql-tools/graphql-file-loader": "^7.5.14",
@@ -1,2 +0,0 @@
1
- #! /usr/bin/env node
2
- export {};
package/dist/cmd/crud.js DELETED
@@ -1,321 +0,0 @@
1
- #! /usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const yargs_1 = __importDefault(require("yargs/yargs"));
8
- const helpers_1 = require("yargs/helpers");
9
- const client_1 = require("../management/client");
10
- const load_1 = require("@graphql-tools/load");
11
- const graphql_file_loader_1 = require("@graphql-tools/graphql-file-loader");
12
- const graphql_1 = require("graphql");
13
- const dotenv_1 = require("dotenv");
14
- const run = async () => {
15
- (0, dotenv_1.config)();
16
- const argv = await (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
17
- .config({
18
- schemaGlob: "./src/**/*.graphql",
19
- permissionsSchemaGlob: "",
20
- serverAddress: "http://127.0.0.1",
21
- apiToken: "",
22
- namespace: "",
23
- })
24
- .pkgConf("crud").argv;
25
- let schemaGlob = argv.schemaGlob;
26
- let permissionsSchemaGlob = argv.permissionsSchemaGlob;
27
- let serverAddress = argv.serverAddress;
28
- let apiToken = argv.apiToken;
29
- let namespace = argv.namespace;
30
- if (process.env.CRUD_SCHEMA_GLOB) {
31
- schemaGlob = process.env.CRUD_SCHEMA_GLOB;
32
- }
33
- if (process.env.PERMISSIONS_SCHEMA_GLOB) {
34
- permissionsSchemaGlob = process.env.PERMISSIONS_SCHEMA_GLOB;
35
- }
36
- if (process.env.CRUD_MANAGEMENT_SERVER_ADDRESS) {
37
- serverAddress = process.env.CRUD_MANAGEMENT_SERVER_ADDRESS;
38
- }
39
- if (process.env.CRUD_MANAGEMENT_API_TOKEN) {
40
- apiToken = process.env.CRUD_MANAGEMENT_API_TOKEN;
41
- }
42
- if (process.env.CRUD_NAMESPACE) {
43
- namespace = process.env.CRUD_NAMESPACE;
44
- }
45
- if (namespace === "Fraym") {
46
- throw new Error("Cannot use Fraym as namespace as it is reserved for fraym apps");
47
- }
48
- const schemaGlobs = [`${schemaGlob}`];
49
- if (permissionsSchemaGlob) {
50
- schemaGlobs.push(`${permissionsSchemaGlob}`);
51
- }
52
- const schema = await (0, load_1.loadSchema)(schemaGlobs, {
53
- loaders: [new graphql_file_loader_1.GraphQLFileLoader()],
54
- });
55
- const definitions = getTypeDefinition(schema, namespace);
56
- await migrateSchemas(definitions, serverAddress, apiToken, namespace);
57
- };
58
- run();
59
- const getTypeDefinition = (schema, namespace) => {
60
- const definitions = {};
61
- schema.toConfig().types.forEach(t => {
62
- if (!(t instanceof graphql_1.GraphQLObjectType) && !(t instanceof graphql_1.GraphQLEnumType)) {
63
- return;
64
- }
65
- const name = `${namespace}${t.toString()}`;
66
- ensureValidName(name);
67
- if (definitions[name]) {
68
- throw new Error(`duplicate definition for type "${name}" detected, try renaming one of them as they have to be uniquely named`);
69
- }
70
- if (t instanceof graphql_1.GraphQLObjectType) {
71
- definitions[name] = getTypeDefinitionFromGraphQLObjectType(t, namespace);
72
- return;
73
- }
74
- if (t instanceof graphql_1.GraphQLEnumType) {
75
- definitions[name] = getTypeDefinitionFromGraphQLEnumType(t, namespace);
76
- return;
77
- }
78
- });
79
- return definitions;
80
- };
81
- const getTypeDefinitionFromGraphQLEnumType = (t, namespace) => {
82
- var _a, _b;
83
- const name = `${namespace}${t.toString()}`;
84
- ensureValidName(name);
85
- let enumValuesString = "";
86
- (_b = (_a = t.astNode) === null || _a === void 0 ? void 0 : _a.values) === null || _b === void 0 ? void 0 : _b.forEach(value => {
87
- enumValuesString += `\n\t${value.name.value}`;
88
- });
89
- const schema = `enum ${name} {${enumValuesString}\n}`;
90
- return {
91
- isCrudType: false,
92
- nestedTypes: [],
93
- schema,
94
- };
95
- };
96
- const getTypeDefinitionFromGraphQLObjectType = (t, namespace) => {
97
- var _a, _b, _c, _d, _e, _f, _g;
98
- const isCrudType = (_c = (((_a = t.astNode) === null || _a === void 0 ? void 0 : _a.directives) &&
99
- ((_b = t.astNode) === null || _b === void 0 ? void 0 : _b.directives.length) > 0 &&
100
- t.astNode.directives[0].name.value === "crudType")) !== null && _c !== void 0 ? _c : false;
101
- const name = `${namespace}${t.toString()}`;
102
- let objectDirectivesString = "";
103
- let objectFieldsString = "";
104
- let nestedTypes = [];
105
- (_e = (_d = t.astNode) === null || _d === void 0 ? void 0 : _d.directives) === null || _e === void 0 ? void 0 : _e.forEach(d => {
106
- objectDirectivesString += getDirectiveString(d);
107
- });
108
- (_g = (_f = t.astNode) === null || _f === void 0 ? void 0 : _f.fields) === null || _g === void 0 ? void 0 : _g.forEach(f => {
109
- const { str, nestedTypes: newNestedTypes } = getFieldStringAndNestedTypes(f, namespace);
110
- objectFieldsString += str;
111
- newNestedTypes.forEach(nested => {
112
- if (nestedTypes.indexOf(nested) === -1) {
113
- nestedTypes.push(nested);
114
- }
115
- });
116
- });
117
- const schema = `type ${name}${objectDirectivesString} {${objectFieldsString}\n}`;
118
- return {
119
- isCrudType,
120
- nestedTypes,
121
- schema,
122
- };
123
- };
124
- const getFieldStringAndNestedTypes = (f, namespace) => {
125
- var _a;
126
- let directivesString = "";
127
- (_a = f.directives) === null || _a === void 0 ? void 0 : _a.forEach(d => {
128
- directivesString += getDirectiveString(d);
129
- });
130
- const { nestedType, str: typeString } = getTypeData(f.type, namespace);
131
- const nestedTypes = [];
132
- if (nestedType) {
133
- nestedTypes.push(nestedType);
134
- }
135
- return {
136
- str: `\n\t${f.name.value}: ${typeString}${directivesString}`,
137
- nestedTypes,
138
- };
139
- };
140
- const getTypeData = (t, namespace) => {
141
- switch (t.kind) {
142
- case graphql_1.Kind.NAMED_TYPE:
143
- const name = t.name.value;
144
- ensureValidName(`${namespace}${name}`);
145
- return name === "String" ||
146
- name === "Float" ||
147
- name === "ID" ||
148
- name === "Boolean" ||
149
- name === "Int" ||
150
- name === "DateTime" ||
151
- name === "File"
152
- ? {
153
- str: name,
154
- }
155
- : {
156
- str: `${namespace}${name}`,
157
- nestedType: `${namespace}${name}`,
158
- };
159
- case graphql_1.Kind.LIST_TYPE:
160
- const { nestedType: listNestedType, str: listStr } = getTypeData(t.type, namespace);
161
- return {
162
- str: `[${listStr}]`,
163
- nestedType: listNestedType,
164
- };
165
- case graphql_1.Kind.NON_NULL_TYPE:
166
- const { nestedType: nonNullNestedType, str: nonNullStr } = getTypeData(t.type, namespace);
167
- return {
168
- str: `${nonNullStr}!`,
169
- nestedType: nonNullNestedType,
170
- };
171
- }
172
- };
173
- const getDirectiveString = (d) => {
174
- if (!d.arguments || d.arguments.length == 0) {
175
- return ` @${d.name.value}`;
176
- }
177
- let argsString = "";
178
- d.arguments.forEach(a => {
179
- if (argsString !== "") {
180
- argsString += ", ";
181
- }
182
- argsString += `${a.name.value}: ${getValueString(a.value)}`;
183
- });
184
- return ` @${d.name.value}(${argsString})`;
185
- };
186
- const getValueString = (v) => {
187
- switch (v.kind) {
188
- case graphql_1.Kind.LIST:
189
- let valuesString = "";
190
- v.values.forEach(el => {
191
- if (valuesString !== "") {
192
- valuesString += ", ";
193
- }
194
- valuesString += getValueString(el);
195
- });
196
- return `[${valuesString}]`;
197
- case graphql_1.Kind.STRING:
198
- return `"${v.value}"`;
199
- case graphql_1.Kind.FLOAT:
200
- case graphql_1.Kind.INT:
201
- case graphql_1.Kind.BOOLEAN:
202
- return `${v.value}`;
203
- case graphql_1.Kind.NULL:
204
- return `null`;
205
- case graphql_1.Kind.ENUM:
206
- return `${v.value}`;
207
- case graphql_1.Kind.OBJECT:
208
- let objectString = "";
209
- v.fields.forEach(f => {
210
- if (objectString !== "") {
211
- objectString += ", ";
212
- }
213
- objectString += `${f.name.value}: ${getValueString(f.value)}`;
214
- });
215
- return `{${objectString}}`;
216
- }
217
- };
218
- const addNestedTypesToSchema = (definitions, nestedTypeName, nestedTypes) => {
219
- const nestedTypeDefinition = definitions[nestedTypeName];
220
- if (nestedTypes.indexOf(nestedTypeName) !== -1 ||
221
- (nestedTypeDefinition && nestedTypeDefinition.isCrudType)) {
222
- return {
223
- schema: "",
224
- nestedTypes: [],
225
- };
226
- }
227
- let newSchema = definitions[nestedTypeName].schema;
228
- if (!nestedTypes.includes(nestedTypeName)) {
229
- nestedTypes.push(nestedTypeName);
230
- }
231
- nestedTypeDefinition.nestedTypes.forEach(nestedNestedTypeName => {
232
- const nestedSchemaData = addNestedTypesToSchema(definitions, nestedNestedTypeName, nestedTypes);
233
- if (nestedSchemaData.schema === "") {
234
- return;
235
- }
236
- newSchema += `\n${nestedSchemaData.schema}`;
237
- nestedSchemaData.nestedTypes.forEach(nestedType => {
238
- if (!nestedTypes.includes(nestedType)) {
239
- nestedTypes.push(nestedType);
240
- }
241
- });
242
- });
243
- return {
244
- schema: newSchema,
245
- nestedTypes: nestedTypes,
246
- };
247
- };
248
- const migrateSchemas = async (definitions, serverAddress, apiToken, namespace) => {
249
- console.log(`Considering ${Object.keys(definitions).length} type definitions for migration.`);
250
- console.log(`Using server address ${serverAddress}`);
251
- console.log(`Using namespace ${namespace}`);
252
- const managementClient = await (0, client_1.newManagementClient)({ serverAddress, apiToken });
253
- const existingTypeNames = (await managementClient.getAllTypes()).filter(name => name.startsWith(namespace) && !name.startsWith("Fraym"));
254
- let createSchema = "";
255
- let updateSchema = "";
256
- const typesToCreate = [];
257
- const nestedTypesToCreate = [];
258
- const typesToUpdate = [];
259
- const nestedTypesToUpdate = [];
260
- const typesToRemove = [];
261
- existingTypeNames.forEach(existingName => {
262
- if (!definitions[existingName] || !definitions[existingName].isCrudType) {
263
- typesToRemove.push(existingName);
264
- }
265
- else {
266
- typesToUpdate.push(existingName);
267
- updateSchema += `\n${definitions[existingName].schema}`;
268
- definitions[existingName].nestedTypes.forEach(nestedTypeName => {
269
- const nestedSchemaData = addNestedTypesToSchema(definitions, nestedTypeName, nestedTypesToUpdate);
270
- if (nestedSchemaData.schema === "") {
271
- return;
272
- }
273
- updateSchema += `\n${nestedSchemaData.schema}`;
274
- nestedSchemaData.nestedTypes.forEach(nestedType => {
275
- if (!nestedTypesToUpdate.includes(nestedType)) {
276
- nestedTypesToUpdate.push(nestedType);
277
- }
278
- });
279
- });
280
- }
281
- });
282
- Object.keys(definitions).forEach(newName => {
283
- if (!definitions[newName].isCrudType || existingTypeNames.includes(newName)) {
284
- return;
285
- }
286
- typesToCreate.push(newName);
287
- createSchema += `\n${definitions[newName].schema}`;
288
- definitions[newName].nestedTypes.forEach(nestedTypeName => {
289
- const nestedSchemaData = addNestedTypesToSchema(definitions, nestedTypeName, nestedTypesToCreate);
290
- if (nestedSchemaData.schema === "") {
291
- return;
292
- }
293
- createSchema += `\n${nestedSchemaData.schema}`;
294
- nestedSchemaData.nestedTypes.forEach(nestedType => {
295
- if (!nestedTypesToCreate.includes(nestedType)) {
296
- nestedTypesToCreate.push(nestedType);
297
- }
298
- });
299
- });
300
- });
301
- if (typesToCreate.length > 0) {
302
- console.log(`Creating ${typesToCreate.length} types: ${typesToCreate}...`);
303
- await managementClient.upsertTypes(createSchema);
304
- console.log(`Created ${typesToCreate.length} types`);
305
- }
306
- if (typesToUpdate.length > 0) {
307
- console.log(`Updating ${typesToUpdate.length} types: ${typesToUpdate}...`);
308
- await managementClient.upsertTypes(updateSchema);
309
- console.log(`Updated ${typesToUpdate.length} types`);
310
- }
311
- if (typesToRemove.length > 0) {
312
- console.log(`Removing ${typesToRemove.length} types: ${typesToRemove}...`);
313
- await managementClient.removeTypes(typesToRemove);
314
- console.log(`Removed ${typesToRemove.length} types`);
315
- }
316
- };
317
- const ensureValidName = (name) => {
318
- if (name.startsWith("Fraym")) {
319
- throw new Error(`Cannot use Fraym as type name prefix as it is reserved for fraym apps, got ${name}`);
320
- }
321
- };
@@ -1,7 +0,0 @@
1
- import { ManagementClientConfig } from "../config/config";
2
- export interface ManagementClient {
3
- upsertTypes: (schema: string) => Promise<void>;
4
- removeTypes: (typeNames: string[]) => Promise<void>;
5
- getAllTypes: () => Promise<string[]>;
6
- }
7
- export declare const newManagementClient: (config?: ManagementClientConfig) => Promise<ManagementClient>;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.newManagementClient = void 0;
4
- const config_1 = require("../config/config");
5
- const getAll_1 = require("./getAll");
6
- const remove_1 = require("./remove");
7
- const upsert_1 = require("./upsert");
8
- const newManagementClient = async (config) => {
9
- const currentConfig = (0, config_1.useManagementConfigDefaults)(config);
10
- const upsertTypes = async (schema) => {
11
- await (0, upsert_1.upsertCrudTypes)(schema, currentConfig);
12
- };
13
- const removeTypes = async (typeNames) => {
14
- await (0, remove_1.removeCrudTypes)(typeNames, currentConfig);
15
- };
16
- const getAllTypes = async () => {
17
- return await (0, getAll_1.getAllCrudTypes)(currentConfig);
18
- };
19
- return {
20
- upsertTypes,
21
- removeTypes,
22
- getAllTypes,
23
- };
24
- };
25
- exports.newManagementClient = newManagementClient;
@@ -1,2 +0,0 @@
1
- import { ManagementClientConfig } from "config/config";
2
- export declare const getAllCrudTypes: (config: ManagementClientConfig) => Promise<string[]>;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAllCrudTypes = void 0;
4
- const getAllCrudTypes = async (config) => {
5
- const response = await fetch(`${config.serverAddress}/management/types`, {
6
- method: "GET",
7
- headers: {
8
- Authorization: `Bearer ${config.apiToken}`,
9
- },
10
- });
11
- if (!response.ok) {
12
- throw new Error(await response.text());
13
- }
14
- const data = await response.json();
15
- return data.typeNames;
16
- };
17
- exports.getAllCrudTypes = getAllCrudTypes;
@@ -1,2 +0,0 @@
1
- import { ManagementClientConfig } from "config/config";
2
- export declare const removeCrudTypes: (typeNames: string[], config: ManagementClientConfig) => Promise<void>;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.removeCrudTypes = void 0;
4
- const removeCrudTypes = async (typeNames, config) => {
5
- const response = await fetch(`${config.serverAddress}/management/types`, {
6
- method: "DELETE",
7
- headers: {
8
- Authorization: `Bearer ${config.apiToken}`,
9
- "Content-Type": "application/json",
10
- },
11
- body: JSON.stringify({
12
- typeNames,
13
- }),
14
- });
15
- if (!response.ok) {
16
- throw new Error(await response.text());
17
- }
18
- };
19
- exports.removeCrudTypes = removeCrudTypes;
@@ -1,2 +0,0 @@
1
- import { ManagementClientConfig } from "config/config";
2
- export declare const upsertCrudTypes: (schema: string, config: ManagementClientConfig) => Promise<void>;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.upsertCrudTypes = void 0;
4
- const upsertCrudTypes = async (schema, config) => {
5
- const response = await fetch(`${config.serverAddress}/management/types`, {
6
- method: "POST",
7
- headers: {
8
- Authorization: `Bearer ${config.apiToken}`,
9
- "Content-Type": "application/json",
10
- },
11
- body: JSON.stringify({
12
- schema,
13
- }),
14
- });
15
- if (!response.ok) {
16
- throw new Error(await response.text());
17
- }
18
- };
19
- exports.upsertCrudTypes = upsertCrudTypes;