@xxmachina/common 0.0.0-PLACEHOLDER
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/_shared/auth/index.d.ts +8 -0
- package/_shared/auth/passports/anonymous/index.d.ts +8 -0
- package/_shared/auth/passports/firebase/index.d.ts +19 -0
- package/_shared/auth/passports/internal/index.d.ts +17 -0
- package/_shared/auth/passports/msal/index.d.ts +26 -0
- package/_shared/meta/index.d.ts +8 -0
- package/_shared/meta/redis/index.d.ts +39 -0
- package/auth/index.d.ts +16 -0
- package/azure-auth/index.d.ts +41 -0
- package/domain/builder/index.d.ts +81 -0
- package/domain/builder/screen-item/index.d.ts +7 -0
- package/domain/index.d.ts +2 -0
- package/domain/models/index.d.ts +517 -0
- package/fesm2022/xxmachina-common-_shared-auth-passports-anonymous.mjs +20 -0
- package/fesm2022/xxmachina-common-_shared-auth-passports-anonymous.mjs.map +1 -0
- package/fesm2022/xxmachina-common-_shared-auth-passports-firebase.mjs +41 -0
- package/fesm2022/xxmachina-common-_shared-auth-passports-firebase.mjs.map +1 -0
- package/fesm2022/xxmachina-common-_shared-auth-passports-internal.mjs +34 -0
- package/fesm2022/xxmachina-common-_shared-auth-passports-internal.mjs.map +1 -0
- package/fesm2022/xxmachina-common-_shared-auth-passports-msal.mjs +49 -0
- package/fesm2022/xxmachina-common-_shared-auth-passports-msal.mjs.map +1 -0
- package/fesm2022/xxmachina-common-_shared-auth.mjs +25 -0
- package/fesm2022/xxmachina-common-_shared-auth.mjs.map +1 -0
- package/fesm2022/xxmachina-common-_shared-meta-redis.mjs +99 -0
- package/fesm2022/xxmachina-common-_shared-meta-redis.mjs.map +1 -0
- package/fesm2022/xxmachina-common-_shared-meta.mjs +26 -0
- package/fesm2022/xxmachina-common-_shared-meta.mjs.map +1 -0
- package/fesm2022/xxmachina-common-auth.mjs +17 -0
- package/fesm2022/xxmachina-common-auth.mjs.map +1 -0
- package/fesm2022/xxmachina-common-azure-auth.mjs +160 -0
- package/fesm2022/xxmachina-common-azure-auth.mjs.map +1 -0
- package/fesm2022/xxmachina-common-domain-builder-screen-item.mjs +201 -0
- package/fesm2022/xxmachina-common-domain-builder-screen-item.mjs.map +1 -0
- package/fesm2022/xxmachina-common-domain-builder.mjs +494 -0
- package/fesm2022/xxmachina-common-domain-builder.mjs.map +1 -0
- package/fesm2022/xxmachina-common-domain-models.mjs +841 -0
- package/fesm2022/xxmachina-common-domain-models.mjs.map +1 -0
- package/fesm2022/xxmachina-common-domain.mjs +7 -0
- package/fesm2022/xxmachina-common-domain.mjs.map +1 -0
- package/fesm2022/xxmachina-common-firebase-auth.mjs +36 -0
- package/fesm2022/xxmachina-common-firebase-auth.mjs.map +1 -0
- package/fesm2022/xxmachina-common-infra-converters-google.mjs +39 -0
- package/fesm2022/xxmachina-common-infra-converters-google.mjs.map +1 -0
- package/fesm2022/xxmachina-common-infra-external-data-connect.mjs +13 -0
- package/fesm2022/xxmachina-common-infra-external-data-connect.mjs.map +1 -0
- package/fesm2022/xxmachina-common-infra-external-quick-js.mjs +61 -0
- package/fesm2022/xxmachina-common-infra-external-quick-js.mjs.map +1 -0
- package/fesm2022/xxmachina-common-infra-external-resend.mjs +10 -0
- package/fesm2022/xxmachina-common-infra-external-resend.mjs.map +1 -0
- package/fesm2022/xxmachina-common-infra-external.mjs +35 -0
- package/fesm2022/xxmachina-common-infra-external.mjs.map +1 -0
- package/fesm2022/xxmachina-common-infra-query-firestore.mjs +33 -0
- package/fesm2022/xxmachina-common-infra-query-firestore.mjs.map +1 -0
- package/fesm2022/xxmachina-common-infra-query-hasura.mjs +20 -0
- package/fesm2022/xxmachina-common-infra-query-hasura.mjs.map +1 -0
- package/fesm2022/xxmachina-common-infra-repository-dataconnect.mjs +18 -0
- package/fesm2022/xxmachina-common-infra-repository-dataconnect.mjs.map +1 -0
- package/fesm2022/xxmachina-common-infra-repository-firestore.mjs +73 -0
- package/fesm2022/xxmachina-common-infra-repository-firestore.mjs.map +1 -0
- package/fesm2022/xxmachina-common-infra-repository-hasura.mjs +41 -0
- package/fesm2022/xxmachina-common-infra-repository-hasura.mjs.map +1 -0
- package/fesm2022/xxmachina-common-infra-repository-notion.mjs +105 -0
- package/fesm2022/xxmachina-common-infra-repository-notion.mjs.map +1 -0
- package/fesm2022/xxmachina-common-infra.mjs +368 -0
- package/fesm2022/xxmachina-common-infra.mjs.map +1 -0
- package/fesm2022/xxmachina-common-invoice-domain-builders.mjs +79 -0
- package/fesm2022/xxmachina-common-invoice-domain-builders.mjs.map +1 -0
- package/fesm2022/xxmachina-common-invoice-domain-models.mjs +432 -0
- package/fesm2022/xxmachina-common-invoice-domain-models.mjs.map +1 -0
- package/fesm2022/xxmachina-common-invoice-domain-resolvers.mjs +41 -0
- package/fesm2022/xxmachina-common-invoice-domain-resolvers.mjs.map +1 -0
- package/fesm2022/xxmachina-common-invoice-domain.mjs +8 -0
- package/fesm2022/xxmachina-common-invoice-domain.mjs.map +1 -0
- package/fesm2022/xxmachina-common-invoice-usecase-contract.mjs +27 -0
- package/fesm2022/xxmachina-common-invoice-usecase-contract.mjs.map +1 -0
- package/fesm2022/xxmachina-common-invoice-usecase-invoice.mjs +191 -0
- package/fesm2022/xxmachina-common-invoice-usecase-invoice.mjs.map +1 -0
- package/fesm2022/xxmachina-common-invoice-usecase-order.mjs +36 -0
- package/fesm2022/xxmachina-common-invoice-usecase-order.mjs.map +1 -0
- package/fesm2022/xxmachina-common-invoice-usecase-partner.mjs +36 -0
- package/fesm2022/xxmachina-common-invoice-usecase-partner.mjs.map +1 -0
- package/fesm2022/xxmachina-common-services-graphql.mjs +323 -0
- package/fesm2022/xxmachina-common-services-graphql.mjs.map +1 -0
- package/fesm2022/xxmachina-common-services-query-config.mjs +44 -0
- package/fesm2022/xxmachina-common-services-query-config.mjs.map +1 -0
- package/fesm2022/xxmachina-common-services-query.mjs +65 -0
- package/fesm2022/xxmachina-common-services-query.mjs.map +1 -0
- package/fesm2022/xxmachina-common-services-speech.mjs +178 -0
- package/fesm2022/xxmachina-common-services-speech.mjs.map +1 -0
- package/fesm2022/xxmachina-common-services-transformer.mjs +27 -0
- package/fesm2022/xxmachina-common-services-transformer.mjs.map +1 -0
- package/fesm2022/xxmachina-common-stores-firestore.mjs +33 -0
- package/fesm2022/xxmachina-common-stores-firestore.mjs.map +1 -0
- package/fesm2022/xxmachina-common-stores-hasura.mjs +32 -0
- package/fesm2022/xxmachina-common-stores-hasura.mjs.map +1 -0
- package/fesm2022/xxmachina-common-stores-inmemory.mjs +102 -0
- package/fesm2022/xxmachina-common-stores-inmemory.mjs.map +1 -0
- package/fesm2022/xxmachina-common-stores.mjs +16 -0
- package/fesm2022/xxmachina-common-stores.mjs.map +1 -0
- package/fesm2022/xxmachina-common-usecase-assistant.mjs +67 -0
- package/fesm2022/xxmachina-common-usecase-assistant.mjs.map +1 -0
- package/fesm2022/xxmachina-common-usecase-database.mjs +95 -0
- package/fesm2022/xxmachina-common-usecase-database.mjs.map +1 -0
- package/fesm2022/xxmachina-common-usecase-graphql.mjs +51 -0
- package/fesm2022/xxmachina-common-usecase-graphql.mjs.map +1 -0
- package/fesm2022/xxmachina-common-usecase-link.mjs +26 -0
- package/fesm2022/xxmachina-common-usecase-link.mjs.map +1 -0
- package/fesm2022/xxmachina-common-usecase-project.mjs +35 -0
- package/fesm2022/xxmachina-common-usecase-project.mjs.map +1 -0
- package/fesm2022/xxmachina-common-usecase-spec.mjs +45 -0
- package/fesm2022/xxmachina-common-usecase-spec.mjs.map +1 -0
- package/fesm2022/xxmachina-common-usecase.mjs +198 -0
- package/fesm2022/xxmachina-common-usecase.mjs.map +1 -0
- package/fesm2022/xxmachina-common-utils-crypto.mjs +30 -0
- package/fesm2022/xxmachina-common-utils-crypto.mjs.map +1 -0
- package/fesm2022/xxmachina-common-utils.mjs +53 -0
- package/fesm2022/xxmachina-common-utils.mjs.map +1 -0
- package/fesm2022/xxmachina-common.mjs +6 -0
- package/fesm2022/xxmachina-common.mjs.map +1 -0
- package/firebase-auth/index.d.ts +6 -0
- package/index.d.ts +1 -0
- package/infra/converters/google/index.d.ts +15 -0
- package/infra/external/data-connect/index.d.ts +7 -0
- package/infra/external/index.d.ts +24 -0
- package/infra/external/quick-js/index.d.ts +24 -0
- package/infra/external/resend/index.d.ts +16 -0
- package/infra/index.d.ts +206 -0
- package/infra/query/firestore/index.d.ts +20 -0
- package/infra/query/hasura/index.d.ts +9 -0
- package/infra/repository/dataconnect/index.d.ts +28 -0
- package/infra/repository/firestore/index.d.ts +42 -0
- package/infra/repository/hasura/index.d.ts +24 -0
- package/infra/repository/notion/index.d.ts +89 -0
- package/invoice/domain/builders/index.d.ts +31 -0
- package/invoice/domain/index.d.ts +3 -0
- package/invoice/domain/models/index.d.ts +78 -0
- package/invoice/domain/resolvers/index.d.ts +15 -0
- package/invoice/usecase/contract/index.d.ts +14 -0
- package/invoice/usecase/invoice/index.d.ts +34 -0
- package/invoice/usecase/order/index.d.ts +16 -0
- package/invoice/usecase/partner/index.d.ts +16 -0
- package/package.json +276 -0
- package/services/graphql/index.d.ts +97 -0
- package/services/query/config/index.d.ts +18 -0
- package/services/query/index.d.ts +29 -0
- package/services/speech/index.d.ts +37 -0
- package/services/transformer/index.d.ts +14 -0
- package/stores/firestore/index.d.ts +17 -0
- package/stores/hasura/index.d.ts +17 -0
- package/stores/index.d.ts +32 -0
- package/stores/inmemory/index.d.ts +33 -0
- package/usecase/assistant/index.d.ts +18 -0
- package/usecase/database/index.d.ts +39 -0
- package/usecase/graphql/index.d.ts +17 -0
- package/usecase/index.d.ts +73 -0
- package/usecase/link/index.d.ts +13 -0
- package/usecase/project/index.d.ts +16 -0
- package/usecase/spec/index.d.ts +17 -0
- package/utils/crypto/index.d.ts +9 -0
- package/utils/index.d.ts +5 -0
|
@@ -0,0 +1,841 @@
|
|
|
1
|
+
import { __decorate, __metadata } from 'tslib';
|
|
2
|
+
import { IsString, IsOptional, ValidateNested } from 'class-validator';
|
|
3
|
+
import { Nullable, Optional, IsDayjs as IsDayjs$1 } from 'class-validator-extended';
|
|
4
|
+
import { Firestore } from '@nx-ddd/firestore';
|
|
5
|
+
import dayjs from 'dayjs';
|
|
6
|
+
import { Domain, TransformToDayjs as TransformToDayjs$1 } from '@nx-ddd/common/domain';
|
|
7
|
+
import { get, merge, pick, camelCase } from 'lodash-es';
|
|
8
|
+
import { extractDisplayFields } from '@xxmachina/common/utils';
|
|
9
|
+
import { createCompoundSchema } from 'genson-js';
|
|
10
|
+
import { parse, visit } from 'graphql';
|
|
11
|
+
import { deepSnakeToCamelCase, Hasura, TransformToDayjs } from '@nx-ddd/hasura';
|
|
12
|
+
import { gql } from 'apollo-angular';
|
|
13
|
+
import { format } from 'prettier';
|
|
14
|
+
import graphqlParser from 'prettier/parser-graphql';
|
|
15
|
+
import { IsDayjs } from '@nx-ddd/core';
|
|
16
|
+
|
|
17
|
+
class Assistant {
|
|
18
|
+
id;
|
|
19
|
+
model;
|
|
20
|
+
name;
|
|
21
|
+
description;
|
|
22
|
+
instructions;
|
|
23
|
+
isPublic;
|
|
24
|
+
sheetUrl;
|
|
25
|
+
}
|
|
26
|
+
__decorate([
|
|
27
|
+
IsString(),
|
|
28
|
+
IsOptional(),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], Assistant.prototype, "model", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
IsString(),
|
|
33
|
+
IsOptional(),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], Assistant.prototype, "name", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
IsString(),
|
|
38
|
+
Nullable(),
|
|
39
|
+
IsOptional(),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], Assistant.prototype, "description", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
IsString(),
|
|
44
|
+
IsOptional(),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], Assistant.prototype, "instructions", void 0);
|
|
47
|
+
|
|
48
|
+
class Bookmarklet {
|
|
49
|
+
id;
|
|
50
|
+
title;
|
|
51
|
+
code;
|
|
52
|
+
userId;
|
|
53
|
+
createdAt;
|
|
54
|
+
updatedAt;
|
|
55
|
+
}
|
|
56
|
+
__decorate([
|
|
57
|
+
Firestore.ID(),
|
|
58
|
+
__metadata("design:type", String)
|
|
59
|
+
], Bookmarklet.prototype, "id", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
Firestore.String(),
|
|
62
|
+
__metadata("design:type", String)
|
|
63
|
+
], Bookmarklet.prototype, "title", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
Firestore.String(),
|
|
66
|
+
__metadata("design:type", String)
|
|
67
|
+
], Bookmarklet.prototype, "code", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
Firestore.String(),
|
|
70
|
+
__metadata("design:type", String)
|
|
71
|
+
], Bookmarklet.prototype, "userId", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
Firestore.Timestamp(),
|
|
74
|
+
__metadata("design:type", dayjs.Dayjs)
|
|
75
|
+
], Bookmarklet.prototype, "createdAt", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
Firestore.Timestamp(),
|
|
78
|
+
__metadata("design:type", dayjs.Dayjs)
|
|
79
|
+
], Bookmarklet.prototype, "updatedAt", void 0);
|
|
80
|
+
|
|
81
|
+
class WebApiRequest {
|
|
82
|
+
contentType;
|
|
83
|
+
responseContentType;
|
|
84
|
+
serverUrl;
|
|
85
|
+
apiJsonUrl;
|
|
86
|
+
path;
|
|
87
|
+
method;
|
|
88
|
+
security;
|
|
89
|
+
bodySchema;
|
|
90
|
+
}
|
|
91
|
+
__decorate([
|
|
92
|
+
Domain.Lang('contentType'),
|
|
93
|
+
__metadata("design:type", String)
|
|
94
|
+
], WebApiRequest.prototype, "contentType", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
Domain.Lang('サーバーURL'),
|
|
97
|
+
__metadata("design:type", String)
|
|
98
|
+
], WebApiRequest.prototype, "serverUrl", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
Domain.Lang('OpenAPI URL'),
|
|
101
|
+
__metadata("design:type", String)
|
|
102
|
+
], WebApiRequest.prototype, "apiJsonUrl", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
Domain.Lang('パス'),
|
|
105
|
+
__metadata("design:type", String)
|
|
106
|
+
], WebApiRequest.prototype, "path", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
Domain.Lang('メソッド'),
|
|
109
|
+
__metadata("design:type", String)
|
|
110
|
+
], WebApiRequest.prototype, "method", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
Domain.Lang('セキュリティ'),
|
|
113
|
+
__metadata("design:type", Array)
|
|
114
|
+
], WebApiRequest.prototype, "security", void 0);
|
|
115
|
+
class WebAPiRequestCommand {
|
|
116
|
+
id;
|
|
117
|
+
name;
|
|
118
|
+
description;
|
|
119
|
+
type;
|
|
120
|
+
webApiRequest;
|
|
121
|
+
}
|
|
122
|
+
__decorate([
|
|
123
|
+
Domain.Lang('説明'),
|
|
124
|
+
__metadata("design:type", String)
|
|
125
|
+
], WebAPiRequestCommand.prototype, "description", void 0);
|
|
126
|
+
|
|
127
|
+
class EndpointHelper {
|
|
128
|
+
static extract(endpoint) {
|
|
129
|
+
if (!endpoint)
|
|
130
|
+
return [];
|
|
131
|
+
console.debug('[CommandPage] endpoint:', endpoint);
|
|
132
|
+
return (endpoint.match(/{(\w+)}/g) || []).map(key => key.slice(1, -1));
|
|
133
|
+
}
|
|
134
|
+
static resolve(endpoint, params) {
|
|
135
|
+
return endpoint.replace(/{(\w+)}/g, (_, key) => {
|
|
136
|
+
if (params[key] === undefined) {
|
|
137
|
+
throw new Error(`Missing parameter: ${key}`);
|
|
138
|
+
}
|
|
139
|
+
return params[key];
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function join(...paths) {
|
|
145
|
+
return paths.map(path => path.replace(/(^\/|\/$)/g, '')).join('/');
|
|
146
|
+
}
|
|
147
|
+
class CommandHelper {
|
|
148
|
+
static resolveEndpoint(command, params) {
|
|
149
|
+
console.debug('CommandHelper.resolveEndpoint', command, params);
|
|
150
|
+
return EndpointHelper.resolve(join(command.webApiRequest.serverUrl || '', command.webApiRequest.path), params);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
class Database {
|
|
155
|
+
id;
|
|
156
|
+
title;
|
|
157
|
+
path;
|
|
158
|
+
properties;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
class GoogleCredential {
|
|
162
|
+
accessToken;
|
|
163
|
+
idToken;
|
|
164
|
+
refreshToken;
|
|
165
|
+
expiresIn;
|
|
166
|
+
photoUrl;
|
|
167
|
+
}
|
|
168
|
+
__decorate([
|
|
169
|
+
Firestore.String(),
|
|
170
|
+
__metadata("design:type", String)
|
|
171
|
+
], GoogleCredential.prototype, "accessToken", void 0);
|
|
172
|
+
__decorate([
|
|
173
|
+
Firestore.String(),
|
|
174
|
+
__metadata("design:type", String)
|
|
175
|
+
], GoogleCredential.prototype, "idToken", void 0);
|
|
176
|
+
__decorate([
|
|
177
|
+
Firestore.String(),
|
|
178
|
+
__metadata("design:type", String)
|
|
179
|
+
], GoogleCredential.prototype, "refreshToken", void 0);
|
|
180
|
+
__decorate([
|
|
181
|
+
Firestore.Number(),
|
|
182
|
+
__metadata("design:type", Number)
|
|
183
|
+
], GoogleCredential.prototype, "expiresIn", void 0);
|
|
184
|
+
__decorate([
|
|
185
|
+
Firestore.String(),
|
|
186
|
+
__metadata("design:type", String)
|
|
187
|
+
], GoogleCredential.prototype, "photoUrl", void 0);
|
|
188
|
+
class Google {
|
|
189
|
+
id = 'google';
|
|
190
|
+
userId;
|
|
191
|
+
credential;
|
|
192
|
+
}
|
|
193
|
+
__decorate([
|
|
194
|
+
Firestore.ID(),
|
|
195
|
+
__metadata("design:type", String)
|
|
196
|
+
], Google.prototype, "id", void 0);
|
|
197
|
+
__decorate([
|
|
198
|
+
Firestore.String(),
|
|
199
|
+
__metadata("design:type", String)
|
|
200
|
+
], Google.prototype, "userId", void 0);
|
|
201
|
+
__decorate([
|
|
202
|
+
Firestore.Map(() => GoogleCredential),
|
|
203
|
+
__metadata("design:type", GoogleCredential)
|
|
204
|
+
], Google.prototype, "credential", void 0);
|
|
205
|
+
|
|
206
|
+
class OpenApi {
|
|
207
|
+
openApi;
|
|
208
|
+
constructor(openApi) {
|
|
209
|
+
this.openApi = openApi;
|
|
210
|
+
}
|
|
211
|
+
get apiJsonUrl() {
|
|
212
|
+
return this.openApi.apiJsonUrl;
|
|
213
|
+
}
|
|
214
|
+
getMethods(path) {
|
|
215
|
+
return OpenApiHelper.getMethods(this.openApi, path);
|
|
216
|
+
}
|
|
217
|
+
getMethod(path, method) {
|
|
218
|
+
return OpenApiHelper.getMethod(this.openApi, path, method);
|
|
219
|
+
}
|
|
220
|
+
getContentType(path, method) {
|
|
221
|
+
return OpenApiHelper.getContentType(this.openApi, path, method);
|
|
222
|
+
}
|
|
223
|
+
getSummary(path, method) {
|
|
224
|
+
return OpenApiHelper.getSummary(this.openApi, path, method);
|
|
225
|
+
}
|
|
226
|
+
getDescription(path, method) {
|
|
227
|
+
return get(this.openApi, ['paths', path, method, 'description']);
|
|
228
|
+
}
|
|
229
|
+
getSecurity(path, method) {
|
|
230
|
+
return get(this.openApi, ['paths', path, method, 'security']);
|
|
231
|
+
}
|
|
232
|
+
getRequestBodySchema(path, method, contentType = this.getContentType(path, method)) {
|
|
233
|
+
return OpenApiHelper.getRequestBodySchema(this.openApi, path, method, contentType);
|
|
234
|
+
}
|
|
235
|
+
getResponseContentType(path, method) {
|
|
236
|
+
return Object.keys(get(this.openApi, ['paths', path, method, 'responses', '200', 'content']) ?? {})[0];
|
|
237
|
+
}
|
|
238
|
+
getOperationId(path, method) {
|
|
239
|
+
return OpenApiHelper.getOperationId(this.openApi, path, method);
|
|
240
|
+
}
|
|
241
|
+
getEndpoints() {
|
|
242
|
+
return OpenApiHelper.getEndpoints(this.openApi);
|
|
243
|
+
}
|
|
244
|
+
getPaths() {
|
|
245
|
+
return OpenApiHelper.getPaths(this.openApi);
|
|
246
|
+
}
|
|
247
|
+
getServerUrl() {
|
|
248
|
+
return this.openApi?.servers?.[0]?.url;
|
|
249
|
+
// ?? (this.openApi. as string).replace(/\/api-json$/, '/api'),
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
class OpenApiHelper {
|
|
253
|
+
static getContentType(openApi, endpoint, method) {
|
|
254
|
+
return Object.keys(get(openApi, ['paths', endpoint, method, 'requestBody', 'content']) ?? {})?.[0] ?? null;
|
|
255
|
+
}
|
|
256
|
+
static getSummary(openApi, endpoint, method) {
|
|
257
|
+
return get(openApi, ['paths', endpoint, method, 'summary']);
|
|
258
|
+
}
|
|
259
|
+
static getOperationId(openApi, endpoint, method) {
|
|
260
|
+
return get(openApi, ['paths', endpoint, method, 'operationId']);
|
|
261
|
+
}
|
|
262
|
+
static getParameters(openApi, endpoint, method) {
|
|
263
|
+
return get(openApi, ['paths', endpoint, method, 'parameters']);
|
|
264
|
+
}
|
|
265
|
+
static getRequestBodySchema(openApi, endpoint, method, contentType = this.getContentType(openApi, endpoint, method)) {
|
|
266
|
+
return get(openApi, ['paths', endpoint, method, 'requestBody', 'content', contentType, 'schema']) ?? 'unkown';
|
|
267
|
+
}
|
|
268
|
+
static getMethod(openApi, endpoint, method) {
|
|
269
|
+
return get(openApi, ['paths', endpoint, method]);
|
|
270
|
+
}
|
|
271
|
+
static getMethods(openApi, endpoint) {
|
|
272
|
+
return Object.keys(get(openApi, ['paths', endpoint]) ?? {});
|
|
273
|
+
}
|
|
274
|
+
static getEndpoints(openApi) {
|
|
275
|
+
return Object.keys(OpenApiHelper.getPaths(openApi));
|
|
276
|
+
}
|
|
277
|
+
static getPaths(openApi) {
|
|
278
|
+
return get(openApi, 'paths') ?? {};
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
var OperatorType;
|
|
283
|
+
(function (OperatorType) {
|
|
284
|
+
OperatorType["ASSISTANT"] = "assistant";
|
|
285
|
+
OperatorType["SYSTEM"] = "system";
|
|
286
|
+
OperatorType["WORKFLOW"] = "workflow";
|
|
287
|
+
})(OperatorType || (OperatorType = {}));
|
|
288
|
+
|
|
289
|
+
const GRAPHQL_QUERY_MAKER = {
|
|
290
|
+
id: 'graphql-query-maker',
|
|
291
|
+
type: OperatorType.ASSISTANT,
|
|
292
|
+
name: 'graphql-query-maker',
|
|
293
|
+
description: 'Make a graphql query',
|
|
294
|
+
inputInterfaceId: 'interfaces:default:plain',
|
|
295
|
+
outputInterfaceId: 'interfaces:default:graphql',
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
var AiType;
|
|
299
|
+
(function (AiType) {
|
|
300
|
+
AiType["OPEN_AI"] = "openai";
|
|
301
|
+
AiType["AZURE_OPEN_AI"] = "azureopenai";
|
|
302
|
+
})(AiType || (AiType = {}));
|
|
303
|
+
|
|
304
|
+
class QueryHelper {
|
|
305
|
+
static validate(query) {
|
|
306
|
+
if (query.graphql.endpoint === '')
|
|
307
|
+
return false;
|
|
308
|
+
return this.validateGraphqlQuery(query.graphql.query);
|
|
309
|
+
}
|
|
310
|
+
static validateGraphqlQuery(query) {
|
|
311
|
+
try {
|
|
312
|
+
gql `${query}`;
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
catch (error) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
static tryParseJson(value, fallback = {}) {
|
|
320
|
+
try {
|
|
321
|
+
return JSON.parse(value);
|
|
322
|
+
}
|
|
323
|
+
catch (error) {
|
|
324
|
+
return fallback;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
static isParseableJson(value) {
|
|
328
|
+
try {
|
|
329
|
+
JSON.parse(value);
|
|
330
|
+
return true;
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
static isExecutableGetSchemaGraphql(query) {
|
|
337
|
+
return !!query?.graphql?.endpoint && QueryHelper.isParseableJson(query?.graphql?.headersJson);
|
|
338
|
+
}
|
|
339
|
+
static setup(query, partialVariables = {}) {
|
|
340
|
+
const parsedQuery = this.tryParse(query);
|
|
341
|
+
const variables = this.mergeVariables(parsedQuery.graphql.variables, partialVariables);
|
|
342
|
+
return {
|
|
343
|
+
...parsedQuery,
|
|
344
|
+
graphql: {
|
|
345
|
+
...parsedQuery?.graphql,
|
|
346
|
+
variablesJson: JSON.stringify(variables, null, 2),
|
|
347
|
+
variables,
|
|
348
|
+
},
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
static mergeVariables(variables, params) {
|
|
352
|
+
return merge(variables, pick(params, Object.keys(variables)));
|
|
353
|
+
}
|
|
354
|
+
static getResult(result, key = Object.keys(result)[0]) {
|
|
355
|
+
return deepSnakeToCamelCase(result[key][0]);
|
|
356
|
+
}
|
|
357
|
+
static getResultErrors(result) {
|
|
358
|
+
return result.errors;
|
|
359
|
+
}
|
|
360
|
+
static throwResultError(result) {
|
|
361
|
+
if (result.errors) {
|
|
362
|
+
throw new Error(result.errors[0].message);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
static tryParse(query) {
|
|
366
|
+
const variables = QueryHelper.tryParseJson(query.graphql.variablesJson);
|
|
367
|
+
const headers = QueryHelper.tryParseJson(query.graphql.headersJson);
|
|
368
|
+
return {
|
|
369
|
+
...query,
|
|
370
|
+
graphql: {
|
|
371
|
+
...query.graphql,
|
|
372
|
+
variables,
|
|
373
|
+
headers,
|
|
374
|
+
},
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
static mapFieldsToColumns(ast) {
|
|
378
|
+
const typeMappings = {};
|
|
379
|
+
ast.definitions.forEach(def => {
|
|
380
|
+
if (def.kind === 'ObjectTypeDefinition') {
|
|
381
|
+
const typeDef = def;
|
|
382
|
+
const typeName = typeDef.name.value;
|
|
383
|
+
const fields = typeDef.fields || [];
|
|
384
|
+
typeMappings[typeName] = {};
|
|
385
|
+
fields.forEach((field) => {
|
|
386
|
+
const fieldName = field.name.value;
|
|
387
|
+
const columnName = camelCase(fieldName);
|
|
388
|
+
typeMappings[typeName][fieldName] = columnName;
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
return typeMappings;
|
|
393
|
+
}
|
|
394
|
+
static snakeToCamelObject(obj) {
|
|
395
|
+
if (obj === null || typeof obj !== 'object')
|
|
396
|
+
return obj;
|
|
397
|
+
if (Array.isArray(obj))
|
|
398
|
+
return obj.map(QueryHelper.snakeToCamelObject);
|
|
399
|
+
return Object.fromEntries(Object.entries(obj).map(([key, value]) => {
|
|
400
|
+
if (key.startsWith('__'))
|
|
401
|
+
return [key, value];
|
|
402
|
+
return [
|
|
403
|
+
key.replace(/_([a-z0-9])/g, (_, c) => c.toUpperCase()),
|
|
404
|
+
QueryHelper.snakeToCamelObject(value),
|
|
405
|
+
];
|
|
406
|
+
}));
|
|
407
|
+
}
|
|
408
|
+
static parseResult(result) {
|
|
409
|
+
const keys = Object.keys(result?.data || {});
|
|
410
|
+
const map = keys.reduce((acc, key) => {
|
|
411
|
+
const items = result?.data?.[key] || [];
|
|
412
|
+
return { ...acc, [key]: QueryHelper.snakeToCamelObject(Array.isArray(items) ? items : [items]) };
|
|
413
|
+
}, {});
|
|
414
|
+
return map;
|
|
415
|
+
}
|
|
416
|
+
static extractColumnNames(items, childrenKey) {
|
|
417
|
+
console.debug('[extractColumnNames] items:', items);
|
|
418
|
+
const schema = createCompoundSchema(items);
|
|
419
|
+
if (!schema)
|
|
420
|
+
return [];
|
|
421
|
+
console.debug('[extractColumnNames] schema:', schema);
|
|
422
|
+
const columnNames = extractDisplayFields(schema).filter(name => !name.endsWith('__typename'));
|
|
423
|
+
console.debug('[extractColumnNames] columnNames:', columnNames);
|
|
424
|
+
const results = [
|
|
425
|
+
// '__checkbox'
|
|
426
|
+
];
|
|
427
|
+
if (childrenKey) {
|
|
428
|
+
const primaryKey = columnNames[0];
|
|
429
|
+
const excludeKeySet = new Set([primaryKey, childrenKey]);
|
|
430
|
+
results.push(`__tree_${primaryKey}`);
|
|
431
|
+
results.push(...columnNames.filter(name => !excludeKeySet.has(name)));
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
results.push(...columnNames);
|
|
435
|
+
}
|
|
436
|
+
return results;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* @deprecated
|
|
440
|
+
*/
|
|
441
|
+
static convertToV2(query) {
|
|
442
|
+
if (query?.type === 'graphql')
|
|
443
|
+
return query;
|
|
444
|
+
return {
|
|
445
|
+
id: query.id,
|
|
446
|
+
projectId: query.projectId,
|
|
447
|
+
type: 'graphql',
|
|
448
|
+
title: query.title,
|
|
449
|
+
summary: query.summary,
|
|
450
|
+
graphql: {
|
|
451
|
+
endpoint: query.endpoint,
|
|
452
|
+
query: query.query,
|
|
453
|
+
headersJson: query.headersJson,
|
|
454
|
+
variablesJson: query.variablesJson,
|
|
455
|
+
transformerTs: '',
|
|
456
|
+
},
|
|
457
|
+
createdAt: query.createdAt,
|
|
458
|
+
updatedAt: query.updatedAt,
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
static overwrite(current, preVariables) {
|
|
462
|
+
const overwrite = Object.entries(current).reduce((acc, [key, value]) => {
|
|
463
|
+
if (!(key in preVariables))
|
|
464
|
+
return acc;
|
|
465
|
+
const preValue = preVariables?.[key] ?? '';
|
|
466
|
+
if (typeof preValue === 'string' && preValue.startsWith('%') && preValue.endsWith('%')) {
|
|
467
|
+
acc[key] = `%${value}%`;
|
|
468
|
+
}
|
|
469
|
+
else if (typeof preValue === 'string' && preValue.startsWith('%')) {
|
|
470
|
+
acc[key] = `%${value}`;
|
|
471
|
+
}
|
|
472
|
+
else if (typeof preValue === 'string' && preValue.endsWith('%')) {
|
|
473
|
+
acc[key] = `${value}%`;
|
|
474
|
+
}
|
|
475
|
+
else if (typeof preValue === 'string') {
|
|
476
|
+
acc[key] = `${value}`;
|
|
477
|
+
}
|
|
478
|
+
else if (Array.isArray(preValue)) {
|
|
479
|
+
acc[key] = value ?? [];
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
acc[key] = value;
|
|
483
|
+
}
|
|
484
|
+
return acc;
|
|
485
|
+
}, {});
|
|
486
|
+
return Object.entries(overwrite).reduce((acc, [key, value]) => ({
|
|
487
|
+
...acc,
|
|
488
|
+
[key]: value,
|
|
489
|
+
}), { ...preVariables });
|
|
490
|
+
}
|
|
491
|
+
static formatGraphql(gql) {
|
|
492
|
+
return format(gql, { parser: 'graphql', plugins: [graphqlParser] });
|
|
493
|
+
}
|
|
494
|
+
static buildTemp(query) {
|
|
495
|
+
return merge({
|
|
496
|
+
id: '',
|
|
497
|
+
type: 'graphql',
|
|
498
|
+
projectId: 'default',
|
|
499
|
+
title: 'Temporary Query',
|
|
500
|
+
summary: '',
|
|
501
|
+
graphql: {
|
|
502
|
+
endpoint: '',
|
|
503
|
+
variablesJson: JSON.stringify({
|
|
504
|
+
id: '$id',
|
|
505
|
+
}, null, 2),
|
|
506
|
+
headersJson: JSON.stringify({
|
|
507
|
+
"content-type": "application/json",
|
|
508
|
+
"Authorization": "Bearer $MACHINA_AUTH_ACCESS_TOKEN"
|
|
509
|
+
}, null, 2),
|
|
510
|
+
query: ``,
|
|
511
|
+
},
|
|
512
|
+
createdAt: undefined,
|
|
513
|
+
updatedAt: undefined,
|
|
514
|
+
}, query);
|
|
515
|
+
}
|
|
516
|
+
static pruneUnusedVariables(variables, query) {
|
|
517
|
+
const ast = parse(query);
|
|
518
|
+
const used = new Set();
|
|
519
|
+
visit(ast, { Variable: (node) => used.add(node.name.value) });
|
|
520
|
+
return Object.fromEntries(Object.entries(variables || {}).filter(([key]) => used.has(key)));
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
class QueryGraphql {
|
|
525
|
+
endpoint;
|
|
526
|
+
query;
|
|
527
|
+
headersJson;
|
|
528
|
+
headers;
|
|
529
|
+
variablesJson;
|
|
530
|
+
variables;
|
|
531
|
+
transformerTs;
|
|
532
|
+
transformer;
|
|
533
|
+
}
|
|
534
|
+
__decorate([
|
|
535
|
+
IsString(),
|
|
536
|
+
Firestore.String(),
|
|
537
|
+
Hasura.Text(),
|
|
538
|
+
__metadata("design:type", String)
|
|
539
|
+
], QueryGraphql.prototype, "endpoint", void 0);
|
|
540
|
+
__decorate([
|
|
541
|
+
IsString(),
|
|
542
|
+
Firestore.String(),
|
|
543
|
+
Hasura.Text(),
|
|
544
|
+
__metadata("design:type", String)
|
|
545
|
+
], QueryGraphql.prototype, "query", void 0);
|
|
546
|
+
__decorate([
|
|
547
|
+
Optional(),
|
|
548
|
+
IsString(),
|
|
549
|
+
Firestore.String(),
|
|
550
|
+
Hasura.Text(),
|
|
551
|
+
__metadata("design:type", String)
|
|
552
|
+
], QueryGraphql.prototype, "headersJson", void 0);
|
|
553
|
+
__decorate([
|
|
554
|
+
Optional(),
|
|
555
|
+
IsString(),
|
|
556
|
+
Firestore.String(),
|
|
557
|
+
Hasura.Text(),
|
|
558
|
+
__metadata("design:type", String)
|
|
559
|
+
], QueryGraphql.prototype, "variablesJson", void 0);
|
|
560
|
+
__decorate([
|
|
561
|
+
Optional(),
|
|
562
|
+
IsString(),
|
|
563
|
+
Firestore.String(),
|
|
564
|
+
Hasura.Text(),
|
|
565
|
+
__metadata("design:type", String)
|
|
566
|
+
], QueryGraphql.prototype, "transformerTs", void 0);
|
|
567
|
+
__decorate([
|
|
568
|
+
Optional(),
|
|
569
|
+
IsString(),
|
|
570
|
+
__metadata("design:type", Function)
|
|
571
|
+
], QueryGraphql.prototype, "transformer", void 0);
|
|
572
|
+
class Query {
|
|
573
|
+
id;
|
|
574
|
+
projectId;
|
|
575
|
+
title;
|
|
576
|
+
summary;
|
|
577
|
+
type;
|
|
578
|
+
graphql;
|
|
579
|
+
createdAt;
|
|
580
|
+
updatedAt;
|
|
581
|
+
static fromParsedObject(object) {
|
|
582
|
+
return {
|
|
583
|
+
...object,
|
|
584
|
+
id: null,
|
|
585
|
+
graphql: {
|
|
586
|
+
...object.graphql,
|
|
587
|
+
variablesJson: JSON.stringify(object.graphql?.variables ?? {}, null, 2),
|
|
588
|
+
headersJson: JSON.stringify(object.graphql?.headers ?? {}, null, 2),
|
|
589
|
+
transformerTs: object.graphql?.transformerTs,
|
|
590
|
+
},
|
|
591
|
+
createdAt: null,
|
|
592
|
+
updatedAt: null,
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
__decorate([
|
|
597
|
+
IsString(),
|
|
598
|
+
Firestore.String(),
|
|
599
|
+
Hasura.Text(),
|
|
600
|
+
__metadata("design:type", String)
|
|
601
|
+
], Query.prototype, "id", void 0);
|
|
602
|
+
__decorate([
|
|
603
|
+
IsString(),
|
|
604
|
+
Firestore.String(),
|
|
605
|
+
Hasura.Text(),
|
|
606
|
+
__metadata("design:type", String)
|
|
607
|
+
], Query.prototype, "projectId", void 0);
|
|
608
|
+
__decorate([
|
|
609
|
+
IsString(),
|
|
610
|
+
Firestore.String(),
|
|
611
|
+
Hasura.Text(),
|
|
612
|
+
__metadata("design:type", String)
|
|
613
|
+
], Query.prototype, "title", void 0);
|
|
614
|
+
__decorate([
|
|
615
|
+
IsString(),
|
|
616
|
+
Firestore.String(),
|
|
617
|
+
Hasura.Text(),
|
|
618
|
+
__metadata("design:type", String)
|
|
619
|
+
], Query.prototype, "summary", void 0);
|
|
620
|
+
__decorate([
|
|
621
|
+
Optional(),
|
|
622
|
+
IsString(),
|
|
623
|
+
Firestore.String(),
|
|
624
|
+
Hasura.Text(),
|
|
625
|
+
__metadata("design:type", String)
|
|
626
|
+
], Query.prototype, "type", void 0);
|
|
627
|
+
__decorate([
|
|
628
|
+
Optional(),
|
|
629
|
+
ValidateNested(),
|
|
630
|
+
Firestore.Map(),
|
|
631
|
+
Hasura.JSON(),
|
|
632
|
+
__metadata("design:type", QueryGraphql)
|
|
633
|
+
], Query.prototype, "graphql", void 0);
|
|
634
|
+
__decorate([
|
|
635
|
+
Nullable(),
|
|
636
|
+
Optional(),
|
|
637
|
+
IsDayjs(),
|
|
638
|
+
TransformToDayjs(),
|
|
639
|
+
Firestore.Timestamp(),
|
|
640
|
+
__metadata("design:type", dayjs.Dayjs)
|
|
641
|
+
], Query.prototype, "createdAt", void 0);
|
|
642
|
+
__decorate([
|
|
643
|
+
Nullable(),
|
|
644
|
+
Optional(),
|
|
645
|
+
IsDayjs(),
|
|
646
|
+
TransformToDayjs(),
|
|
647
|
+
Firestore.Timestamp(),
|
|
648
|
+
__metadata("design:type", dayjs.Dayjs)
|
|
649
|
+
], Query.prototype, "updatedAt", void 0);
|
|
650
|
+
|
|
651
|
+
class ResourceHelper {
|
|
652
|
+
static getDescription(resource) {
|
|
653
|
+
if (resource.type === 'openapi') {
|
|
654
|
+
return resource?.openapi?.url ?? '';
|
|
655
|
+
}
|
|
656
|
+
else if (resource.type === 'graphql') {
|
|
657
|
+
return resource?.graphql?.url ?? '';
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
let Resource = class Resource {
|
|
663
|
+
id;
|
|
664
|
+
projectId;
|
|
665
|
+
name;
|
|
666
|
+
type;
|
|
667
|
+
openapi;
|
|
668
|
+
graphql;
|
|
669
|
+
createdAt;
|
|
670
|
+
updatedAt;
|
|
671
|
+
};
|
|
672
|
+
__decorate([
|
|
673
|
+
Domain.Lang('ID'),
|
|
674
|
+
Firestore.String(),
|
|
675
|
+
Hasura.Text(),
|
|
676
|
+
__metadata("design:type", String)
|
|
677
|
+
], Resource.prototype, "id", void 0);
|
|
678
|
+
__decorate([
|
|
679
|
+
Domain.Lang('プロジェクトID'),
|
|
680
|
+
Firestore.String(),
|
|
681
|
+
Hasura.Text(),
|
|
682
|
+
__metadata("design:type", String)
|
|
683
|
+
], Resource.prototype, "projectId", void 0);
|
|
684
|
+
__decorate([
|
|
685
|
+
Domain.Lang('名称'),
|
|
686
|
+
Firestore.String(),
|
|
687
|
+
Hasura.Text(),
|
|
688
|
+
__metadata("design:type", String)
|
|
689
|
+
], Resource.prototype, "name", void 0);
|
|
690
|
+
__decorate([
|
|
691
|
+
Domain.Lang('種別'),
|
|
692
|
+
Firestore.String(),
|
|
693
|
+
Hasura.Text(),
|
|
694
|
+
__metadata("design:type", String)
|
|
695
|
+
], Resource.prototype, "type", void 0);
|
|
696
|
+
__decorate([
|
|
697
|
+
Domain.Lang('OpenAPI設定'),
|
|
698
|
+
Optional(),
|
|
699
|
+
Firestore.Map(),
|
|
700
|
+
Hasura.JSON(),
|
|
701
|
+
__metadata("design:type", Object)
|
|
702
|
+
], Resource.prototype, "openapi", void 0);
|
|
703
|
+
__decorate([
|
|
704
|
+
Domain.Lang('GraphQL設定'),
|
|
705
|
+
Optional(),
|
|
706
|
+
Firestore.Map(),
|
|
707
|
+
Hasura.JSON(),
|
|
708
|
+
__metadata("design:type", Object)
|
|
709
|
+
], Resource.prototype, "graphql", void 0);
|
|
710
|
+
__decorate([
|
|
711
|
+
Nullable(),
|
|
712
|
+
Optional(),
|
|
713
|
+
IsDayjs(),
|
|
714
|
+
TransformToDayjs$1(),
|
|
715
|
+
Firestore.Timestamp(),
|
|
716
|
+
Hasura.Timestamp(),
|
|
717
|
+
__metadata("design:type", dayjs.Dayjs)
|
|
718
|
+
], Resource.prototype, "createdAt", void 0);
|
|
719
|
+
__decorate([
|
|
720
|
+
Nullable(),
|
|
721
|
+
Optional(),
|
|
722
|
+
IsDayjs(),
|
|
723
|
+
TransformToDayjs$1(),
|
|
724
|
+
Firestore.Timestamp(),
|
|
725
|
+
Hasura.Timestamp(),
|
|
726
|
+
__metadata("design:type", dayjs.Dayjs)
|
|
727
|
+
], Resource.prototype, "updatedAt", void 0);
|
|
728
|
+
Resource = __decorate([
|
|
729
|
+
Domain.Entity({ name: 'リソース' })
|
|
730
|
+
], Resource);
|
|
731
|
+
|
|
732
|
+
class Schedule {
|
|
733
|
+
id;
|
|
734
|
+
calendarId;
|
|
735
|
+
url;
|
|
736
|
+
name;
|
|
737
|
+
color;
|
|
738
|
+
startAt;
|
|
739
|
+
endAt;
|
|
740
|
+
static from(params) {
|
|
741
|
+
const schedule = new Schedule();
|
|
742
|
+
Object.assign(schedule, {
|
|
743
|
+
name: '',
|
|
744
|
+
calendarId: 'primary',
|
|
745
|
+
...params
|
|
746
|
+
});
|
|
747
|
+
return schedule;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
__decorate([
|
|
751
|
+
IsString(),
|
|
752
|
+
__metadata("design:type", String)
|
|
753
|
+
], Schedule.prototype, "id", void 0);
|
|
754
|
+
__decorate([
|
|
755
|
+
IsString(),
|
|
756
|
+
__metadata("design:type", String)
|
|
757
|
+
], Schedule.prototype, "calendarId", void 0);
|
|
758
|
+
__decorate([
|
|
759
|
+
IsString(),
|
|
760
|
+
IsOptional(),
|
|
761
|
+
__metadata("design:type", String)
|
|
762
|
+
], Schedule.prototype, "url", void 0);
|
|
763
|
+
__decorate([
|
|
764
|
+
IsString(),
|
|
765
|
+
__metadata("design:type", String)
|
|
766
|
+
], Schedule.prototype, "name", void 0);
|
|
767
|
+
__decorate([
|
|
768
|
+
IsString(),
|
|
769
|
+
__metadata("design:type", String)
|
|
770
|
+
], Schedule.prototype, "color", void 0);
|
|
771
|
+
__decorate([
|
|
772
|
+
IsDayjs$1(),
|
|
773
|
+
TransformToDayjs$1(),
|
|
774
|
+
__metadata("design:type", dayjs.Dayjs)
|
|
775
|
+
], Schedule.prototype, "startAt", void 0);
|
|
776
|
+
__decorate([
|
|
777
|
+
IsDayjs$1(),
|
|
778
|
+
TransformToDayjs$1(),
|
|
779
|
+
__metadata("design:type", dayjs.Dayjs)
|
|
780
|
+
], Schedule.prototype, "endAt", void 0);
|
|
781
|
+
function isConflict(a, b) {
|
|
782
|
+
if (a.startAt.isSame(b.endAt))
|
|
783
|
+
return false;
|
|
784
|
+
if (a.endAt.isSame(b.startAt))
|
|
785
|
+
return false;
|
|
786
|
+
if (a.startAt.isBefore(b.startAt) && a.endAt.isBefore(b.startAt))
|
|
787
|
+
return false;
|
|
788
|
+
if (a.startAt.isAfter(b.endAt) && a.endAt.isAfter(b.endAt))
|
|
789
|
+
return false;
|
|
790
|
+
return true;
|
|
791
|
+
}
|
|
792
|
+
class Calendar {
|
|
793
|
+
id;
|
|
794
|
+
name;
|
|
795
|
+
color;
|
|
796
|
+
static from(params) {
|
|
797
|
+
const calendar = new Calendar();
|
|
798
|
+
Object.assign(calendar, params);
|
|
799
|
+
return calendar;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
function buildCalendarDate(dates) {
|
|
803
|
+
const minDate = dates.reduce((min, date) => date.date.isBefore(min) ? date.date : min, dates[0].date);
|
|
804
|
+
const maxDate = dates.reduce((max, date) => date.date.isAfter(max) ? date.date : max, dates[0].date);
|
|
805
|
+
const startDate = minDate.clone().startOf('week');
|
|
806
|
+
const endDate = maxDate.clone().endOf('week');
|
|
807
|
+
// console.debug('startDate', startDate.format('YYYY/MM/DD'));
|
|
808
|
+
// console.debug('endDate', endDate.format('YYYY/MM/DD'));
|
|
809
|
+
const month = [];
|
|
810
|
+
let date = startDate.clone();
|
|
811
|
+
while (date.isBefore(endDate)) {
|
|
812
|
+
const week = [];
|
|
813
|
+
for (let i = 0; i < 7; i++) {
|
|
814
|
+
const found = dates.find(d => d.date.isSame(date, 'day'));
|
|
815
|
+
week.push(found || { schedules: [], date: date.clone() });
|
|
816
|
+
date = date.add(1, 'day');
|
|
817
|
+
}
|
|
818
|
+
month.push(week);
|
|
819
|
+
}
|
|
820
|
+
return month;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
let Transformer = class Transformer {
|
|
824
|
+
id;
|
|
825
|
+
script;
|
|
826
|
+
inputJsonSchema;
|
|
827
|
+
outputJsonSchema;
|
|
828
|
+
createdAt;
|
|
829
|
+
updatedAt;
|
|
830
|
+
specs;
|
|
831
|
+
};
|
|
832
|
+
Transformer = __decorate([
|
|
833
|
+
Hasura.Table('xxmachina_transformers')
|
|
834
|
+
], Transformer);
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* Generated bundle index. Do not edit.
|
|
838
|
+
*/
|
|
839
|
+
|
|
840
|
+
export { AiType, Assistant, Bookmarklet, Calendar, CommandHelper, Database, EndpointHelper, GRAPHQL_QUERY_MAKER, Google, GoogleCredential, OpenApi, OpenApiHelper, OperatorType, Query, QueryGraphql, QueryHelper, Resource, ResourceHelper, Schedule, Transformer, WebAPiRequestCommand, WebApiRequest, buildCalendarDate, isConflict };
|
|
841
|
+
//# sourceMappingURL=xxmachina-common-domain-models.mjs.map
|