@donotdev/functions 0.0.16 → 0.0.18
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/lib/firebase/index.js +558 -1515
- package/lib/firebase/index.js.map +4 -4
- package/lib/shared/index.js +163 -333
- package/lib/shared/index.js.map +4 -4
- package/lib/vercel/api/index.js +190 -325
- package/lib/vercel/api/index.js.map +4 -4
- package/package.json +4 -4
- package/src/firebase/baseFunction.ts +4 -5
- package/src/firebase/billing/changePlan.ts +1 -1
- package/src/firebase/billing/createCheckoutSession.ts +4 -4
- package/src/firebase/billing/refreshSubscriptionStatus.ts +1 -1
- package/src/firebase/crud/create.ts +16 -6
- package/src/firebase/crud/delete.ts +0 -6
- package/src/firebase/crud/list.ts +12 -8
- package/src/firebase/crud/update.ts +1 -1
- package/src/firebase/oauth/exchangeToken.ts +7 -2
- package/src/firebase/oauth/getConnections.ts +2 -1
- package/src/shared/billing/__tests__/createCheckout.test.ts +7 -5
- package/src/shared/billing/__tests__/webhookHandler.test.ts +1 -0
- package/src/shared/billing/createCheckout.ts +2 -2
- package/src/shared/billing/helpers/subscriptionManagement.ts +2 -2
- package/src/shared/billing/idempotency.ts +39 -0
- package/src/shared/billing/webhookHandler.ts +19 -17
- package/src/shared/errorHandling.ts +2 -1
- package/src/shared/oauth/__tests__/exchangeToken.test.ts +2 -1
- package/src/shared/schema.ts +1 -1
- package/src/shared/utils/__tests__/functionWrapper.test.ts +1 -1
- package/src/shared/utils/firebaseHelpers.ts +1 -1
- package/src/shared/utils/internal/auth.ts +1 -1
- package/src/shared/utils/internal/idempotency.ts +4 -72
- package/src/shared/utils/internal/rateLimiter.ts +1 -1
- package/src/shared/utils/internal/validation.ts +4 -1
- package/src/shared/utils/vercelHelpers.ts +1 -2
- package/src/shared/validation.ts +1 -1
- package/src/supabase/baseFunction.ts +7 -5
- package/src/supabase/billing/createCheckoutSession.ts +2 -3
- package/src/supabase/billing/refreshSubscriptionStatus.ts +2 -1
- package/src/supabase/crud/aggregate.ts +0 -1
- package/src/supabase/crud/create.ts +4 -2
- package/src/supabase/crud/get.ts +0 -1
- package/src/supabase/crud/list.ts +1 -2
- package/src/supabase/crud/update.ts +0 -1
- package/src/supabase/helpers/authProvider.ts +0 -1
- package/src/supabase/utils/rateLimiter.ts +4 -2
- package/src/vercel/api/billing/change-plan.ts +1 -1
- package/src/vercel/api/billing/create-checkout-session.ts +1 -2
- package/src/vercel/api/billing/refresh-subscription-status.ts +1 -1
- package/src/vercel/api/crud/create.ts +1 -1
- package/src/vercel/api/crud/delete.ts +1 -1
- package/src/vercel/api/crud/get.ts +1 -1
- package/src/vercel/api/crud/list.ts +3 -3
- package/src/vercel/api/crud/update.ts +1 -1
- package/src/vercel/api/oauth/check-github-access.ts +1 -2
- package/src/vercel/api/oauth/exchange-token.ts +1 -2
- package/src/vercel/api/oauth/grant-github-access.ts +1 -2
- package/src/vercel/baseFunction.ts +3 -2
package/lib/firebase/index.js
CHANGED
|
@@ -11,6 +11,59 @@ var __export = (target, all) => {
|
|
|
11
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
// ../core/utils/src/common/arrayTranslations.ts
|
|
15
|
+
var init_arrayTranslations = __esm({
|
|
16
|
+
'../core/utils/src/common/arrayTranslations.ts'() {
|
|
17
|
+
'use strict';
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// ../core/utils/src/common/createMetadata.ts
|
|
22
|
+
var init_createMetadata = __esm({
|
|
23
|
+
'../core/utils/src/common/createMetadata.ts'() {
|
|
24
|
+
'use strict';
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// ../core/utils/src/common/dateUtils.ts
|
|
29
|
+
var init_dateUtils = __esm({
|
|
30
|
+
'../core/utils/src/common/dateUtils.ts'() {
|
|
31
|
+
'use strict';
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// ../core/types/src/auth/constants.ts
|
|
36
|
+
var USER_ROLES, SUBSCRIPTION_TIERS, FEATURES, PERMISSIONS;
|
|
37
|
+
var init_constants = __esm({
|
|
38
|
+
'../core/types/src/auth/constants.ts'() {
|
|
39
|
+
'use strict';
|
|
40
|
+
USER_ROLES = {
|
|
41
|
+
GUEST: 'guest',
|
|
42
|
+
USER: 'user',
|
|
43
|
+
ADMIN: 'admin',
|
|
44
|
+
SUPER: 'super',
|
|
45
|
+
};
|
|
46
|
+
SUBSCRIPTION_TIERS = {
|
|
47
|
+
FREE: 'free',
|
|
48
|
+
PRO: 'pro',
|
|
49
|
+
PREMIUM: 'premium',
|
|
50
|
+
};
|
|
51
|
+
FEATURES = {
|
|
52
|
+
BASIC_ACCESS: 'basic_access',
|
|
53
|
+
ADVANCED_FEATURES: 'advanced_features',
|
|
54
|
+
API_ACCESS: 'api_access',
|
|
55
|
+
PRIORITY_SUPPORT: 'priority_support',
|
|
56
|
+
};
|
|
57
|
+
PERMISSIONS = {
|
|
58
|
+
READ_PUBLIC: 'read_public',
|
|
59
|
+
READ_OWN_DATA: 'read_own_data',
|
|
60
|
+
WRITE_OWN_DATA: 'write_own_data',
|
|
61
|
+
READ_ALL_DATA: 'read_all_data',
|
|
62
|
+
MANAGE_USERS: 'manage_users',
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
14
67
|
// ../../node_modules/.bun/valibot@1.2.0+1fb4c65d43e298b9/node_modules/valibot/dist/index.mjs
|
|
15
68
|
// @__NO_SIDE_EFFECTS__
|
|
16
69
|
function getGlobalConfig(config$1) {
|
|
@@ -377,26 +430,6 @@ function boolean(message$1) {
|
|
|
377
430
|
};
|
|
378
431
|
}
|
|
379
432
|
// @__NO_SIDE_EFFECTS__
|
|
380
|
-
function custom(check$1, message$1) {
|
|
381
|
-
return {
|
|
382
|
-
kind: 'schema',
|
|
383
|
-
type: 'custom',
|
|
384
|
-
reference: custom,
|
|
385
|
-
expects: 'unknown',
|
|
386
|
-
async: false,
|
|
387
|
-
check: check$1,
|
|
388
|
-
message: message$1,
|
|
389
|
-
get '~standard'() {
|
|
390
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
391
|
-
},
|
|
392
|
-
'~run'(dataset, config$1) {
|
|
393
|
-
if (this.check(dataset.value)) dataset.typed = true;
|
|
394
|
-
else _addIssue(this, 'type', dataset, config$1);
|
|
395
|
-
return dataset;
|
|
396
|
-
},
|
|
397
|
-
};
|
|
398
|
-
}
|
|
399
|
-
// @__NO_SIDE_EFFECTS__
|
|
400
433
|
function literal(literal_, message$1) {
|
|
401
434
|
return {
|
|
402
435
|
kind: 'schema',
|
|
@@ -553,32 +586,6 @@ function nullable(wrapped, default_) {
|
|
|
553
586
|
};
|
|
554
587
|
}
|
|
555
588
|
// @__NO_SIDE_EFFECTS__
|
|
556
|
-
function nullish(wrapped, default_) {
|
|
557
|
-
return {
|
|
558
|
-
kind: 'schema',
|
|
559
|
-
type: 'nullish',
|
|
560
|
-
reference: nullish,
|
|
561
|
-
expects: `(${wrapped.expects} | null | undefined)`,
|
|
562
|
-
async: false,
|
|
563
|
-
wrapped,
|
|
564
|
-
default: default_,
|
|
565
|
-
get '~standard'() {
|
|
566
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
567
|
-
},
|
|
568
|
-
'~run'(dataset, config$1) {
|
|
569
|
-
if (dataset.value === null || dataset.value === void 0) {
|
|
570
|
-
if (this.default !== void 0)
|
|
571
|
-
dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
|
|
572
|
-
if (dataset.value === null || dataset.value === void 0) {
|
|
573
|
-
dataset.typed = true;
|
|
574
|
-
return dataset;
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
return this.wrapped['~run'](dataset, config$1);
|
|
578
|
-
},
|
|
579
|
-
};
|
|
580
|
-
}
|
|
581
|
-
// @__NO_SIDE_EFFECTS__
|
|
582
589
|
function number(message$1) {
|
|
583
590
|
return {
|
|
584
591
|
kind: 'schema',
|
|
@@ -1152,12 +1159,10 @@ var init_dist = __esm({
|
|
|
1152
1159
|
__name(any, 'any');
|
|
1153
1160
|
__name(array, 'array');
|
|
1154
1161
|
__name(boolean, 'boolean');
|
|
1155
|
-
__name(custom, 'custom');
|
|
1156
1162
|
__name(literal, 'literal');
|
|
1157
1163
|
__name(looseObject, 'looseObject');
|
|
1158
1164
|
__name(never, 'never');
|
|
1159
1165
|
__name(nullable, 'nullable');
|
|
1160
|
-
__name(nullish, 'nullish');
|
|
1161
1166
|
__name(number, 'number');
|
|
1162
1167
|
__name(object, 'object');
|
|
1163
1168
|
__name(optional, 'optional');
|
|
@@ -1175,66 +1180,6 @@ var init_dist = __esm({
|
|
|
1175
1180
|
},
|
|
1176
1181
|
});
|
|
1177
1182
|
|
|
1178
|
-
// ../core/utils/src/common/arrayTranslations.ts
|
|
1179
|
-
var init_arrayTranslations = __esm({
|
|
1180
|
-
'../core/utils/src/common/arrayTranslations.ts'() {
|
|
1181
|
-
'use strict';
|
|
1182
|
-
},
|
|
1183
|
-
});
|
|
1184
|
-
|
|
1185
|
-
// ../core/utils/src/common/createMetadata.ts
|
|
1186
|
-
var init_createMetadata = __esm({
|
|
1187
|
-
'../core/utils/src/common/createMetadata.ts'() {
|
|
1188
|
-
'use strict';
|
|
1189
|
-
},
|
|
1190
|
-
});
|
|
1191
|
-
|
|
1192
|
-
// ../core/utils/src/common/currencyFormat.ts
|
|
1193
|
-
var init_currencyFormat = __esm({
|
|
1194
|
-
'../core/utils/src/common/currencyFormat.ts'() {
|
|
1195
|
-
'use strict';
|
|
1196
|
-
},
|
|
1197
|
-
});
|
|
1198
|
-
|
|
1199
|
-
// ../core/utils/src/common/dateUtils.ts
|
|
1200
|
-
var init_dateUtils = __esm({
|
|
1201
|
-
'../core/utils/src/common/dateUtils.ts'() {
|
|
1202
|
-
'use strict';
|
|
1203
|
-
},
|
|
1204
|
-
});
|
|
1205
|
-
|
|
1206
|
-
// ../core/types/src/auth/constants.ts
|
|
1207
|
-
var USER_ROLES, SUBSCRIPTION_TIERS, FEATURES, PERMISSIONS;
|
|
1208
|
-
var init_constants = __esm({
|
|
1209
|
-
'../core/types/src/auth/constants.ts'() {
|
|
1210
|
-
'use strict';
|
|
1211
|
-
USER_ROLES = {
|
|
1212
|
-
GUEST: 'guest',
|
|
1213
|
-
USER: 'user',
|
|
1214
|
-
ADMIN: 'admin',
|
|
1215
|
-
SUPER: 'super',
|
|
1216
|
-
};
|
|
1217
|
-
SUBSCRIPTION_TIERS = {
|
|
1218
|
-
FREE: 'free',
|
|
1219
|
-
PRO: 'pro',
|
|
1220
|
-
PREMIUM: 'premium',
|
|
1221
|
-
};
|
|
1222
|
-
FEATURES = {
|
|
1223
|
-
BASIC_ACCESS: 'basic_access',
|
|
1224
|
-
ADVANCED_FEATURES: 'advanced_features',
|
|
1225
|
-
API_ACCESS: 'api_access',
|
|
1226
|
-
PRIORITY_SUPPORT: 'priority_support',
|
|
1227
|
-
};
|
|
1228
|
-
PERMISSIONS = {
|
|
1229
|
-
READ_PUBLIC: 'read_public',
|
|
1230
|
-
READ_OWN_DATA: 'read_own_data',
|
|
1231
|
-
WRITE_OWN_DATA: 'write_own_data',
|
|
1232
|
-
READ_ALL_DATA: 'read_all_data',
|
|
1233
|
-
MANAGE_USERS: 'manage_users',
|
|
1234
|
-
};
|
|
1235
|
-
},
|
|
1236
|
-
});
|
|
1237
|
-
|
|
1238
1183
|
// ../core/types/src/billing/constants.ts
|
|
1239
1184
|
var SUBSCRIPTION_STATUS, STRIPE_MODES, DEFAULT_SUBSCRIPTION;
|
|
1240
1185
|
var init_constants2 = __esm({
|
|
@@ -1542,13 +1487,6 @@ var init_aggregate = __esm({
|
|
|
1542
1487
|
},
|
|
1543
1488
|
});
|
|
1544
1489
|
|
|
1545
|
-
// ../core/types/src/crud/components.ts
|
|
1546
|
-
var init_components = __esm({
|
|
1547
|
-
'../core/types/src/crud/components.ts'() {
|
|
1548
|
-
'use strict';
|
|
1549
|
-
},
|
|
1550
|
-
});
|
|
1551
|
-
|
|
1552
1490
|
// ../core/types/src/crud/constants.ts
|
|
1553
1491
|
var init_constants3 = __esm({
|
|
1554
1492
|
'../core/types/src/crud/constants.ts'() {
|
|
@@ -1629,7 +1567,6 @@ var init_crud = __esm({
|
|
|
1629
1567
|
'../core/types/src/crud/index.ts'() {
|
|
1630
1568
|
'use strict';
|
|
1631
1569
|
init_aggregate();
|
|
1632
|
-
init_components();
|
|
1633
1570
|
init_schemas3();
|
|
1634
1571
|
init_types3();
|
|
1635
1572
|
},
|
|
@@ -3377,13 +3314,6 @@ var init_errors2 = __esm({
|
|
|
3377
3314
|
},
|
|
3378
3315
|
});
|
|
3379
3316
|
|
|
3380
|
-
// ../core/utils/src/common/generateFirestoreRuleCondition.ts
|
|
3381
|
-
var init_generateFirestoreRuleCondition = __esm({
|
|
3382
|
-
'../core/utils/src/common/generateFirestoreRuleCondition.ts'() {
|
|
3383
|
-
'use strict';
|
|
3384
|
-
},
|
|
3385
|
-
});
|
|
3386
|
-
|
|
3387
3317
|
// ../core/utils/src/common/maybeTranslate.ts
|
|
3388
3318
|
var init_maybeTranslate = __esm({
|
|
3389
3319
|
'../core/utils/src/common/maybeTranslate.ts'() {
|
|
@@ -3505,19 +3435,9 @@ function isFieldVisible(visibility, userRole) {
|
|
|
3505
3435
|
if (level === 'technical') {
|
|
3506
3436
|
return hasRoleAccess(userRole, 'admin');
|
|
3507
3437
|
}
|
|
3508
|
-
if (level === 'owner') {
|
|
3509
|
-
return false;
|
|
3510
|
-
}
|
|
3511
3438
|
return hasRoleAccess(userRole, level);
|
|
3512
3439
|
}
|
|
3513
|
-
function
|
|
3514
|
-
for (const field of ownership.ownerFields) {
|
|
3515
|
-
const value = documentData[field];
|
|
3516
|
-
if (value === uid) return true;
|
|
3517
|
-
}
|
|
3518
|
-
return false;
|
|
3519
|
-
}
|
|
3520
|
-
function getVisibleFields(schema, userRole, options) {
|
|
3440
|
+
function getVisibleFields(schema, userRole) {
|
|
3521
3441
|
const schemaAny = schema;
|
|
3522
3442
|
if (!schemaAny || typeof schemaAny !== 'object' || !schemaAny.entries) {
|
|
3523
3443
|
console.warn(
|
|
@@ -3527,18 +3447,8 @@ function getVisibleFields(schema, userRole, options) {
|
|
|
3527
3447
|
}
|
|
3528
3448
|
const entries = schemaAny.entries;
|
|
3529
3449
|
const visibleFieldNames = [];
|
|
3530
|
-
const { documentData, uid, ownership } = options ?? {};
|
|
3531
|
-
const showOwnerFields =
|
|
3532
|
-
ownership &&
|
|
3533
|
-
uid != null &&
|
|
3534
|
-
documentData &&
|
|
3535
|
-
isOwnerVisible(documentData, uid, ownership);
|
|
3536
3450
|
for (const [key, field] of Object.entries(entries)) {
|
|
3537
3451
|
const visibility = getFieldVisibility(field);
|
|
3538
|
-
if (visibility === 'owner') {
|
|
3539
|
-
if (showOwnerFields) visibleFieldNames.push(key);
|
|
3540
|
-
continue;
|
|
3541
|
-
}
|
|
3542
3452
|
if (isFieldVisible(visibility, userRole)) {
|
|
3543
3453
|
visibleFieldNames.push(key);
|
|
3544
3454
|
}
|
|
@@ -3552,29 +3462,16 @@ var init_getVisibleFields = __esm({
|
|
|
3552
3462
|
__name(hasVisibility, 'hasVisibility');
|
|
3553
3463
|
__name(getFieldVisibility, 'getFieldVisibility');
|
|
3554
3464
|
__name(isFieldVisible, 'isFieldVisible');
|
|
3555
|
-
__name(isOwnerVisible, 'isOwnerVisible');
|
|
3556
3465
|
__name(getVisibleFields, 'getVisibleFields');
|
|
3557
3466
|
},
|
|
3558
3467
|
});
|
|
3559
3468
|
|
|
3560
3469
|
// ../core/utils/src/common/schema/filterVisibleFields.ts
|
|
3561
|
-
function filterVisibleFields(data, schema, userRole
|
|
3470
|
+
function filterVisibleFields(data, schema, userRole) {
|
|
3562
3471
|
if (!data) {
|
|
3563
3472
|
return {};
|
|
3564
3473
|
}
|
|
3565
|
-
const
|
|
3566
|
-
options?.uid != null && options?.ownership != null
|
|
3567
|
-
? {
|
|
3568
|
-
documentData: options.documentData ?? data,
|
|
3569
|
-
uid: options.uid,
|
|
3570
|
-
ownership: options.ownership,
|
|
3571
|
-
}
|
|
3572
|
-
: void 0;
|
|
3573
|
-
const visibleFieldNames = getVisibleFields(
|
|
3574
|
-
schema,
|
|
3575
|
-
userRole,
|
|
3576
|
-
visibilityOptions
|
|
3577
|
-
);
|
|
3474
|
+
const visibleFieldNames = getVisibleFields(schema, userRole);
|
|
3578
3475
|
const result = {};
|
|
3579
3476
|
for (const key of visibleFieldNames) {
|
|
3580
3477
|
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
@@ -3606,10 +3503,8 @@ var init_common2 = __esm({
|
|
|
3606
3503
|
'use strict';
|
|
3607
3504
|
init_arrayTranslations();
|
|
3608
3505
|
init_createMetadata();
|
|
3609
|
-
init_currencyFormat();
|
|
3610
3506
|
init_dateUtils();
|
|
3611
3507
|
init_errors2();
|
|
3612
|
-
init_generateFirestoreRuleCondition();
|
|
3613
3508
|
init_maybeTranslate();
|
|
3614
3509
|
init_pkce();
|
|
3615
3510
|
init_gracefulInit();
|
|
@@ -3653,13 +3548,17 @@ var init_server = __esm({
|
|
|
3653
3548
|
},
|
|
3654
3549
|
});
|
|
3655
3550
|
|
|
3551
|
+
// ../core/schemas/src/common/validation/enhanceSchema.ts
|
|
3552
|
+
var init_enhanceSchema = __esm({
|
|
3553
|
+
'../core/schemas/src/common/validation/enhanceSchema.ts'() {
|
|
3554
|
+
'use strict';
|
|
3555
|
+
},
|
|
3556
|
+
});
|
|
3557
|
+
|
|
3656
3558
|
// ../core/schemas/src/common/validation/getSchemaType.ts
|
|
3657
3559
|
function registerSchemaGenerator(type, generator) {
|
|
3658
3560
|
schemaRegistry.set(type, generator);
|
|
3659
3561
|
}
|
|
3660
|
-
function applyRequired(schema, required) {
|
|
3661
|
-
return required ? schema : nullish(schema);
|
|
3662
|
-
}
|
|
3663
3562
|
function registerBuiltinSchemas() {
|
|
3664
3563
|
registerSchemaGenerator('text', textSchema);
|
|
3665
3564
|
registerSchemaGenerator('textarea', textSchema);
|
|
@@ -3669,17 +3568,10 @@ function registerBuiltinSchemas() {
|
|
|
3669
3568
|
registerSchemaGenerator('password', passwordSchema);
|
|
3670
3569
|
registerSchemaGenerator('url', urlSchema);
|
|
3671
3570
|
registerSchemaGenerator('tel', telSchema);
|
|
3672
|
-
registerSchemaGenerator('iban', ibanSchema);
|
|
3673
3571
|
registerSchemaGenerator('number', numberSchema);
|
|
3674
|
-
registerSchemaGenerator('currency', numberSchema);
|
|
3675
|
-
registerSchemaGenerator('price', priceSchema);
|
|
3676
3572
|
registerSchemaGenerator('range', numberSchema);
|
|
3677
|
-
registerSchemaGenerator('year', numberSchema);
|
|
3678
|
-
registerSchemaGenerator('rating', numberSchema);
|
|
3679
|
-
registerSchemaGenerator('duration', numberSchema);
|
|
3680
3573
|
registerSchemaGenerator('boolean', booleanSchema);
|
|
3681
3574
|
registerSchemaGenerator('checkbox', booleanSchema);
|
|
3682
|
-
registerSchemaGenerator('gdprConsent', gdprConsentSchema);
|
|
3683
3575
|
registerSchemaGenerator('date', dateSchema);
|
|
3684
3576
|
registerSchemaGenerator('datetime-local', dateSchema);
|
|
3685
3577
|
registerSchemaGenerator('time', dateSchema);
|
|
@@ -3699,8 +3591,6 @@ function registerBuiltinSchemas() {
|
|
|
3699
3591
|
registerSchemaGenerator('select', selectSchema);
|
|
3700
3592
|
registerSchemaGenerator('multiselect', multiselectSchema);
|
|
3701
3593
|
registerSchemaGenerator('radio', selectSchema);
|
|
3702
|
-
registerSchemaGenerator('combobox', selectSchema);
|
|
3703
|
-
registerSchemaGenerator('switch', switchSchema);
|
|
3704
3594
|
registerSchemaGenerator('reference', referenceSchema);
|
|
3705
3595
|
registerSchemaGenerator('hidden', stringSchema);
|
|
3706
3596
|
registerSchemaGenerator('avatar', stringSchema);
|
|
@@ -3709,17 +3599,13 @@ function registerBuiltinSchemas() {
|
|
|
3709
3599
|
registerSchemaGenerator('reset', neverSchema);
|
|
3710
3600
|
}
|
|
3711
3601
|
function getSchemaType(field) {
|
|
3712
|
-
if (field.validation?.schema) {
|
|
3713
|
-
const customSchema = field.validation.schema;
|
|
3714
|
-
return applyRequired(customSchema, field.validation?.required);
|
|
3715
|
-
}
|
|
3716
3602
|
const generator = schemaRegistry.get(field.type);
|
|
3717
3603
|
if (generator) {
|
|
3718
3604
|
const schema2 = generator(field);
|
|
3719
3605
|
if (schema2 !== null) return schema2;
|
|
3720
3606
|
}
|
|
3721
3607
|
const schema = unknown();
|
|
3722
|
-
return
|
|
3608
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3723
3609
|
}
|
|
3724
3610
|
var schemaRegistry,
|
|
3725
3611
|
textSchema,
|
|
@@ -3744,11 +3630,7 @@ var schemaRegistry,
|
|
|
3744
3630
|
referenceSchema,
|
|
3745
3631
|
stringSchema,
|
|
3746
3632
|
telSchema,
|
|
3747
|
-
|
|
3748
|
-
neverSchema,
|
|
3749
|
-
switchSchema,
|
|
3750
|
-
gdprConsentSchema,
|
|
3751
|
-
priceSchema;
|
|
3633
|
+
neverSchema;
|
|
3752
3634
|
var init_getSchemaType = __esm({
|
|
3753
3635
|
'../core/schemas/src/common/validation/getSchemaType.ts'() {
|
|
3754
3636
|
'use strict';
|
|
@@ -3756,7 +3638,6 @@ var init_getSchemaType = __esm({
|
|
|
3756
3638
|
init_src();
|
|
3757
3639
|
schemaRegistry = /* @__PURE__ */ new Map();
|
|
3758
3640
|
__name(registerSchemaGenerator, 'registerSchemaGenerator');
|
|
3759
|
-
__name(applyRequired, 'applyRequired');
|
|
3760
3641
|
textSchema = /* @__PURE__ */ __name((field) => {
|
|
3761
3642
|
const validations = [];
|
|
3762
3643
|
if (field.validation?.minLength !== void 0) {
|
|
@@ -3782,11 +3663,11 @@ var init_getSchemaType = __esm({
|
|
|
3782
3663
|
}
|
|
3783
3664
|
const schema =
|
|
3784
3665
|
validations.length > 0 ? pipe(string(), ...validations) : string();
|
|
3785
|
-
return
|
|
3666
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3786
3667
|
}, 'textSchema');
|
|
3787
3668
|
emailSchema = /* @__PURE__ */ __name((field) => {
|
|
3788
3669
|
const schema = pipe(string(), email('Invalid email address'));
|
|
3789
|
-
return
|
|
3670
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3790
3671
|
}, 'emailSchema');
|
|
3791
3672
|
passwordSchema = /* @__PURE__ */ __name((field) => {
|
|
3792
3673
|
const schema =
|
|
@@ -3799,11 +3680,11 @@ var init_getSchemaType = __esm({
|
|
|
3799
3680
|
)
|
|
3800
3681
|
)
|
|
3801
3682
|
: string();
|
|
3802
|
-
return
|
|
3683
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3803
3684
|
}, 'passwordSchema');
|
|
3804
3685
|
urlSchema = /* @__PURE__ */ __name((field) => {
|
|
3805
3686
|
const schema = pipe(string(), url('Invalid URL'));
|
|
3806
|
-
return
|
|
3687
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3807
3688
|
}, 'urlSchema');
|
|
3808
3689
|
numberSchema = /* @__PURE__ */ __name((field) => {
|
|
3809
3690
|
const validations = [];
|
|
@@ -3825,30 +3706,30 @@ var init_getSchemaType = __esm({
|
|
|
3825
3706
|
}
|
|
3826
3707
|
const schema =
|
|
3827
3708
|
validations.length > 0 ? pipe(number(), ...validations) : number();
|
|
3828
|
-
return
|
|
3709
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3829
3710
|
}, 'numberSchema');
|
|
3830
3711
|
booleanSchema = /* @__PURE__ */ __name((field) => {
|
|
3831
3712
|
const schema = boolean();
|
|
3832
|
-
return
|
|
3713
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3833
3714
|
}, 'booleanSchema');
|
|
3834
3715
|
dateSchema = /* @__PURE__ */ __name((field) => {
|
|
3835
3716
|
const schema = pipe(string(), isoTimestamp('Invalid date format'));
|
|
3836
|
-
return
|
|
3717
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3837
3718
|
}, 'dateSchema');
|
|
3838
3719
|
fileAssetObjectSchema = object({
|
|
3839
3720
|
url: string(),
|
|
3840
3721
|
filename: string(),
|
|
3841
3722
|
size: number(),
|
|
3842
|
-
mimeType:
|
|
3843
|
-
uploadedAt:
|
|
3723
|
+
mimeType: optional(string()),
|
|
3724
|
+
uploadedAt: optional(string()),
|
|
3844
3725
|
});
|
|
3845
3726
|
fileSchema = /* @__PURE__ */ __name((field) => {
|
|
3846
3727
|
const schema = nullable(fileAssetObjectSchema);
|
|
3847
|
-
return
|
|
3728
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3848
3729
|
}, 'fileSchema');
|
|
3849
3730
|
filesSchema = /* @__PURE__ */ __name((field) => {
|
|
3850
3731
|
const schema = array(fileAssetObjectSchema);
|
|
3851
|
-
return
|
|
3732
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3852
3733
|
}, 'filesSchema');
|
|
3853
3734
|
pictureObjectSchema = object({
|
|
3854
3735
|
fullUrl: string(),
|
|
@@ -3856,149 +3737,126 @@ var init_getSchemaType = __esm({
|
|
|
3856
3737
|
});
|
|
3857
3738
|
pictureSchema = /* @__PURE__ */ __name((field) => {
|
|
3858
3739
|
const schema = pictureObjectSchema;
|
|
3859
|
-
return
|
|
3740
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3860
3741
|
}, 'pictureSchema');
|
|
3861
3742
|
picturesSchema = /* @__PURE__ */ __name((field) => {
|
|
3862
3743
|
const schema = array(pictureObjectSchema);
|
|
3863
|
-
return
|
|
3744
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3864
3745
|
}, 'picturesSchema');
|
|
3865
3746
|
geopointSchema = /* @__PURE__ */ __name((field) => {
|
|
3866
3747
|
const schema = object({ lat: number(), lng: number() });
|
|
3867
|
-
return
|
|
3748
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3868
3749
|
}, 'geopointSchema');
|
|
3869
3750
|
addressSchema = /* @__PURE__ */ __name((field) => {
|
|
3870
3751
|
const schema = object({
|
|
3871
3752
|
formatted_address: string(),
|
|
3872
3753
|
latitude: number(),
|
|
3873
3754
|
longitude: number(),
|
|
3874
|
-
street_number:
|
|
3875
|
-
route:
|
|
3876
|
-
locality:
|
|
3877
|
-
administrative_area_level_1:
|
|
3878
|
-
administrative_area_level_2:
|
|
3879
|
-
country:
|
|
3880
|
-
postal_code:
|
|
3755
|
+
street_number: optional(string()),
|
|
3756
|
+
route: optional(string()),
|
|
3757
|
+
locality: optional(string()),
|
|
3758
|
+
administrative_area_level_1: optional(string()),
|
|
3759
|
+
administrative_area_level_2: optional(string()),
|
|
3760
|
+
country: optional(string()),
|
|
3761
|
+
postal_code: optional(string()),
|
|
3881
3762
|
});
|
|
3882
|
-
return
|
|
3763
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3883
3764
|
}, 'addressSchema');
|
|
3884
3765
|
mapSchema = /* @__PURE__ */ __name((field) => {
|
|
3885
3766
|
const schema = record(string(), unknown());
|
|
3886
|
-
return
|
|
3767
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3887
3768
|
}, 'mapSchema');
|
|
3888
3769
|
arraySchema = /* @__PURE__ */ __name((field) => {
|
|
3889
3770
|
const schema = array(unknown());
|
|
3890
|
-
return
|
|
3771
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3891
3772
|
}, 'arraySchema');
|
|
3892
3773
|
selectSchema = /* @__PURE__ */ __name((field) => {
|
|
3893
3774
|
const options = field.validation?.options;
|
|
3894
3775
|
if (Array.isArray(options) && options.length > 0) {
|
|
3895
3776
|
const values = options.map((opt) => opt.value);
|
|
3896
3777
|
const schema2 = picklist(values);
|
|
3897
|
-
return
|
|
3778
|
+
return field.validation?.required ? schema2 : optional(schema2);
|
|
3898
3779
|
}
|
|
3899
|
-
const schema =
|
|
3900
|
-
return
|
|
3780
|
+
const schema = string();
|
|
3781
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3901
3782
|
}, 'selectSchema');
|
|
3902
3783
|
multiselectSchema = /* @__PURE__ */ __name((field) => {
|
|
3903
3784
|
const options = field.validation?.options;
|
|
3904
3785
|
if (Array.isArray(options) && options.length > 0) {
|
|
3905
3786
|
const values = options.map((opt) => opt.value);
|
|
3906
3787
|
const schema2 = array(picklist(values));
|
|
3907
|
-
return
|
|
3788
|
+
return field.validation?.required ? schema2 : optional(schema2);
|
|
3908
3789
|
}
|
|
3909
3790
|
const schema = array(string());
|
|
3910
|
-
return
|
|
3791
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3911
3792
|
}, 'multiselectSchema');
|
|
3912
3793
|
referenceSchema = /* @__PURE__ */ __name((field) => {
|
|
3913
3794
|
const schema = pipe(
|
|
3914
3795
|
string(),
|
|
3915
3796
|
regex(FIRESTORE_ID_PATTERN, 'Invalid ID format')
|
|
3916
3797
|
);
|
|
3917
|
-
return
|
|
3798
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3918
3799
|
}, 'referenceSchema');
|
|
3919
3800
|
stringSchema = /* @__PURE__ */ __name((field) => {
|
|
3920
3801
|
const schema = string();
|
|
3921
|
-
return
|
|
3802
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3922
3803
|
}, 'stringSchema');
|
|
3923
3804
|
telSchema = /* @__PURE__ */ __name((field) => {
|
|
3924
3805
|
const schema = string();
|
|
3925
|
-
return
|
|
3806
|
+
return field.validation?.required ? schema : optional(schema);
|
|
3926
3807
|
}, 'telSchema');
|
|
3927
|
-
ibanSchema = /* @__PURE__ */ __name((field) => {
|
|
3928
|
-
const minLength2 = field.validation?.minLength ?? 15;
|
|
3929
|
-
const maxLength2 = field.validation?.maxLength ?? 34;
|
|
3930
|
-
const pattern =
|
|
3931
|
-
field.validation?.pattern ?? '^[A-Z]{2}[0-9]{2}[A-Z0-9]{4,34}$';
|
|
3932
|
-
const validations = [];
|
|
3933
|
-
if (minLength2 !== void 0) {
|
|
3934
|
-
validations.push(
|
|
3935
|
-
minLength(
|
|
3936
|
-
minLength2,
|
|
3937
|
-
`IBAN must be at least ${minLength2} characters`
|
|
3938
|
-
)
|
|
3939
|
-
);
|
|
3940
|
-
}
|
|
3941
|
-
if (maxLength2 !== void 0) {
|
|
3942
|
-
validations.push(
|
|
3943
|
-
maxLength(maxLength2, `IBAN must not exceed ${maxLength2} characters`)
|
|
3944
|
-
);
|
|
3945
|
-
}
|
|
3946
|
-
if (pattern) {
|
|
3947
|
-
const regex2 =
|
|
3948
|
-
typeof pattern === 'string' ? new RegExp(pattern) : pattern;
|
|
3949
|
-
validations.push(regex(regex2, 'Invalid IBAN format'));
|
|
3950
|
-
}
|
|
3951
|
-
const schema =
|
|
3952
|
-
validations.length > 0 ? pipe(string(), ...validations) : string();
|
|
3953
|
-
return applyRequired(schema, field.validation?.required);
|
|
3954
|
-
}, 'ibanSchema');
|
|
3955
3808
|
neverSchema = /* @__PURE__ */ __name(() => never(), 'neverSchema');
|
|
3956
|
-
switchSchema = /* @__PURE__ */ __name((field) => {
|
|
3957
|
-
const fieldSpecific = field.options?.fieldSpecific;
|
|
3958
|
-
if (fieldSpecific?.checkedValue && fieldSpecific?.uncheckedValue) {
|
|
3959
|
-
const values = [
|
|
3960
|
-
fieldSpecific.checkedValue,
|
|
3961
|
-
fieldSpecific.uncheckedValue,
|
|
3962
|
-
];
|
|
3963
|
-
const schema2 = picklist(values);
|
|
3964
|
-
return applyRequired(schema2, field.validation?.required);
|
|
3965
|
-
}
|
|
3966
|
-
const schema = boolean();
|
|
3967
|
-
return applyRequired(schema, field.validation?.required);
|
|
3968
|
-
}, 'switchSchema');
|
|
3969
|
-
gdprConsentSchema = /* @__PURE__ */ __name((field) => {
|
|
3970
|
-
const baseSchema = custom((input) => {
|
|
3971
|
-
if (field.validation?.required) {
|
|
3972
|
-
if (typeof input === 'object' && input !== null) {
|
|
3973
|
-
return input.gdprConsent === true;
|
|
3974
|
-
}
|
|
3975
|
-
return false;
|
|
3976
|
-
}
|
|
3977
|
-
if (input === false || input === null || input === void 0) {
|
|
3978
|
-
return true;
|
|
3979
|
-
}
|
|
3980
|
-
if (typeof input === 'object' && input !== null) {
|
|
3981
|
-
return input.gdprConsent === true;
|
|
3982
|
-
}
|
|
3983
|
-
return false;
|
|
3984
|
-
}, 'GDPR consent must be given');
|
|
3985
|
-
return baseSchema;
|
|
3986
|
-
}, 'gdprConsentSchema');
|
|
3987
|
-
priceSchema = /* @__PURE__ */ __name((field) => {
|
|
3988
|
-
const schema = object({
|
|
3989
|
-
amount: number(),
|
|
3990
|
-
currency: optional(string()),
|
|
3991
|
-
vatIncluded: optional(boolean()),
|
|
3992
|
-
discountPercent: optional(pipe(number(), minValue(0), maxValue(100))),
|
|
3993
|
-
});
|
|
3994
|
-
return applyRequired(schema, field.validation?.required);
|
|
3995
|
-
}, 'priceSchema');
|
|
3996
3809
|
__name(registerBuiltinSchemas, 'registerBuiltinSchemas');
|
|
3997
3810
|
registerBuiltinSchemas();
|
|
3998
3811
|
__name(getSchemaType, 'getSchemaType');
|
|
3999
3812
|
},
|
|
4000
3813
|
});
|
|
4001
3814
|
|
|
3815
|
+
// ../core/schemas/src/common/validation/validateDates.ts
|
|
3816
|
+
var init_validateDates = __esm({
|
|
3817
|
+
'../core/schemas/src/common/validation/validateDates.ts'() {
|
|
3818
|
+
'use strict';
|
|
3819
|
+
init_server();
|
|
3820
|
+
},
|
|
3821
|
+
});
|
|
3822
|
+
|
|
3823
|
+
// ../core/schemas/src/common/validation/validateUniqueFields.ts
|
|
3824
|
+
var init_validateUniqueFields = __esm({
|
|
3825
|
+
'../core/schemas/src/common/validation/validateUniqueFields.ts'() {
|
|
3826
|
+
'use strict';
|
|
3827
|
+
init_server();
|
|
3828
|
+
},
|
|
3829
|
+
});
|
|
3830
|
+
|
|
3831
|
+
// ../core/schemas/src/common/validation/validateDocument.ts
|
|
3832
|
+
var init_validateDocument = __esm({
|
|
3833
|
+
'../core/schemas/src/common/validation/validateDocument.ts'() {
|
|
3834
|
+
'use strict';
|
|
3835
|
+
init_validateDates();
|
|
3836
|
+
init_validateUniqueFields();
|
|
3837
|
+
},
|
|
3838
|
+
});
|
|
3839
|
+
|
|
3840
|
+
// ../core/schemas/src/common/validation/index.ts
|
|
3841
|
+
var init_validation2 = __esm({
|
|
3842
|
+
'../core/schemas/src/common/validation/index.ts'() {
|
|
3843
|
+
'use strict';
|
|
3844
|
+
init_enhanceSchema();
|
|
3845
|
+
init_getSchemaType();
|
|
3846
|
+
init_validateDates();
|
|
3847
|
+
init_validateDocument();
|
|
3848
|
+
init_validateUniqueFields();
|
|
3849
|
+
},
|
|
3850
|
+
});
|
|
3851
|
+
|
|
3852
|
+
// ../core/schemas/src/common/utils.ts
|
|
3853
|
+
var init_utils2 = __esm({
|
|
3854
|
+
'../core/schemas/src/common/utils.ts'() {
|
|
3855
|
+
'use strict';
|
|
3856
|
+
init_server();
|
|
3857
|
+
},
|
|
3858
|
+
});
|
|
3859
|
+
|
|
4002
3860
|
// ../core/schemas/src/common/visibility.ts
|
|
4003
3861
|
var DEFAULT_STATUS_OPTIONS,
|
|
4004
3862
|
DEFAULT_STATUS_VALUE,
|
|
@@ -4011,9 +3869,9 @@ var init_visibility = __esm({
|
|
|
4011
3869
|
'use strict';
|
|
4012
3870
|
init_src();
|
|
4013
3871
|
DEFAULT_STATUS_OPTIONS = [
|
|
4014
|
-
{ value: 'draft', label: '
|
|
4015
|
-
{ value: 'available', label: '
|
|
4016
|
-
{ value: 'deleted', label: '
|
|
3872
|
+
{ value: 'draft', label: 'dndev:status.draft' },
|
|
3873
|
+
{ value: 'available', label: 'dndev:status.available' },
|
|
3874
|
+
{ value: 'deleted', label: 'dndev:status.deleted' },
|
|
4017
3875
|
];
|
|
4018
3876
|
DEFAULT_STATUS_VALUE = 'available';
|
|
4019
3877
|
HIDDEN_STATUSES = ['draft', 'deleted'];
|
|
@@ -4035,60 +3893,57 @@ var init_visibility = __esm({
|
|
|
4035
3893
|
// Framework-enforced, user-settable (NOT backend-generated)
|
|
4036
3894
|
];
|
|
4037
3895
|
baseFields = {
|
|
4038
|
-
status: {
|
|
4039
|
-
name: 'status',
|
|
4040
|
-
type: 'select',
|
|
4041
|
-
visibility: 'admin',
|
|
4042
|
-
label: 'crud:fields.status',
|
|
4043
|
-
editable: 'admin',
|
|
4044
|
-
// REQUIRED: Status must be editable to be included in forms
|
|
4045
|
-
validation: {
|
|
4046
|
-
required: true,
|
|
4047
|
-
options: [...DEFAULT_STATUS_OPTIONS],
|
|
4048
|
-
},
|
|
4049
|
-
},
|
|
4050
3896
|
id: {
|
|
4051
|
-
name: 'id',
|
|
4052
3897
|
type: 'text',
|
|
4053
|
-
visibility: '
|
|
4054
|
-
label: 'crud:fields.id',
|
|
3898
|
+
visibility: 'technical',
|
|
4055
3899
|
validation: {
|
|
4056
3900
|
required: true,
|
|
4057
3901
|
pattern: FIRESTORE_ID_PATTERN.source,
|
|
4058
3902
|
},
|
|
4059
3903
|
},
|
|
4060
3904
|
createdAt: {
|
|
4061
|
-
name: '_createdAt',
|
|
4062
3905
|
type: 'timestamp',
|
|
4063
3906
|
visibility: 'technical',
|
|
4064
|
-
label: 'crud:fields._createdAt',
|
|
4065
3907
|
validation: { required: true },
|
|
4066
3908
|
},
|
|
4067
3909
|
updatedAt: {
|
|
4068
|
-
name: '_updatedAt',
|
|
4069
3910
|
type: 'timestamp',
|
|
4070
3911
|
visibility: 'technical',
|
|
4071
|
-
label: 'crud:fields._updatedAt',
|
|
4072
3912
|
validation: { required: true },
|
|
4073
3913
|
},
|
|
4074
3914
|
createdById: {
|
|
4075
|
-
name: '_createdById',
|
|
4076
3915
|
type: 'reference',
|
|
4077
3916
|
visibility: 'technical',
|
|
4078
|
-
label: 'crud:fields._createdById',
|
|
4079
3917
|
validation: { required: true },
|
|
4080
3918
|
},
|
|
4081
3919
|
updatedById: {
|
|
4082
|
-
name: '_updatedById',
|
|
4083
3920
|
type: 'reference',
|
|
4084
3921
|
visibility: 'technical',
|
|
4085
|
-
label: 'crud:fields._updatedById',
|
|
4086
3922
|
validation: { required: true },
|
|
4087
3923
|
},
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
3924
|
+
status: {
|
|
3925
|
+
type: 'select',
|
|
3926
|
+
visibility: 'admin',
|
|
3927
|
+
editable: 'admin',
|
|
3928
|
+
// REQUIRED: Status must be editable to be included in forms
|
|
3929
|
+
validation: {
|
|
3930
|
+
required: true,
|
|
3931
|
+
options: [...DEFAULT_STATUS_OPTIONS],
|
|
3932
|
+
},
|
|
3933
|
+
},
|
|
3934
|
+
};
|
|
3935
|
+
},
|
|
3936
|
+
});
|
|
3937
|
+
|
|
3938
|
+
// ../core/schemas/src/common/defineEntity.ts
|
|
3939
|
+
var init_defineEntity = __esm({
|
|
3940
|
+
'../core/schemas/src/common/defineEntity.ts'() {
|
|
3941
|
+
'use strict';
|
|
3942
|
+
init_server();
|
|
3943
|
+
init_visibility();
|
|
3944
|
+
},
|
|
3945
|
+
});
|
|
3946
|
+
|
|
4092
3947
|
// ../core/schemas/src/common/createSchema.ts
|
|
4093
3948
|
function withVisibility(schema, visibility) {
|
|
4094
3949
|
return Object.assign(schema, { visibility });
|
|
@@ -4098,8 +3953,6 @@ function withMetadata(schema, entity) {
|
|
|
4098
3953
|
enhanced.metadata = {
|
|
4099
3954
|
collection: entity.collection,
|
|
4100
3955
|
entity: entity.name,
|
|
4101
|
-
// Propagate uniqueKeys for backend CRUD functions
|
|
4102
|
-
...(entity.uniqueKeys && { uniqueKeys: entity.uniqueKeys }),
|
|
4103
3956
|
};
|
|
4104
3957
|
return enhanced;
|
|
4105
3958
|
}
|
|
@@ -4155,41 +4008,7 @@ function createSchemas(entity) {
|
|
|
4155
4008
|
}
|
|
4156
4009
|
updateShape['id'] = withVisibility(getSchemaType(baseFields.id), 'technical');
|
|
4157
4010
|
const updateSchema = withMetadata(object(updateShape), entity);
|
|
4158
|
-
|
|
4159
|
-
if (entity.listFields && entity.listFields.length > 0) {
|
|
4160
|
-
const mandatoryFields = ['id', 'status'];
|
|
4161
|
-
const allListFields = [
|
|
4162
|
-
.../* @__PURE__ */ new Set([...mandatoryFields, ...entity.listFields]),
|
|
4163
|
-
];
|
|
4164
|
-
listShape = {};
|
|
4165
|
-
for (const fieldName of allListFields) {
|
|
4166
|
-
const field = getShape[fieldName];
|
|
4167
|
-
if (field) {
|
|
4168
|
-
listShape[fieldName] = field;
|
|
4169
|
-
}
|
|
4170
|
-
}
|
|
4171
|
-
} else {
|
|
4172
|
-
listShape = getShape;
|
|
4173
|
-
}
|
|
4174
|
-
const listSchema = withMetadata(object(listShape), entity);
|
|
4175
|
-
let listCardShape;
|
|
4176
|
-
const fieldsToUse = entity.listCardFields ?? entity.listFields;
|
|
4177
|
-
if (fieldsToUse && fieldsToUse.length > 0) {
|
|
4178
|
-
const mandatoryFields = ['id', 'status'];
|
|
4179
|
-
const allListCardFields = [
|
|
4180
|
-
.../* @__PURE__ */ new Set([...mandatoryFields, ...fieldsToUse]),
|
|
4181
|
-
];
|
|
4182
|
-
listCardShape = {};
|
|
4183
|
-
for (const fieldName of allListCardFields) {
|
|
4184
|
-
const field = getShape[fieldName];
|
|
4185
|
-
if (field) {
|
|
4186
|
-
listCardShape[fieldName] = field;
|
|
4187
|
-
}
|
|
4188
|
-
}
|
|
4189
|
-
} else {
|
|
4190
|
-
listCardShape = getShape;
|
|
4191
|
-
}
|
|
4192
|
-
const listCardSchema = withMetadata(object(listCardShape), entity);
|
|
4011
|
+
const listSchema = withMetadata(array(object(getShape)), entity);
|
|
4193
4012
|
const deleteSchema = withMetadata(
|
|
4194
4013
|
object({
|
|
4195
4014
|
id: withVisibility(getSchemaType(baseFields.id), 'technical'),
|
|
@@ -4202,7 +4021,6 @@ function createSchemas(entity) {
|
|
|
4202
4021
|
update: updateSchema,
|
|
4203
4022
|
get: getSchema,
|
|
4204
4023
|
list: listSchema,
|
|
4205
|
-
listCard: listCardSchema,
|
|
4206
4024
|
delete: deleteSchema,
|
|
4207
4025
|
};
|
|
4208
4026
|
}
|
|
@@ -4221,90 +4039,6 @@ var init_createSchema = __esm({
|
|
|
4221
4039
|
},
|
|
4222
4040
|
});
|
|
4223
4041
|
|
|
4224
|
-
// ../core/schemas/src/client/index.ts
|
|
4225
|
-
var init_client = __esm({
|
|
4226
|
-
'../core/schemas/src/client/index.ts'() {
|
|
4227
|
-
'use strict';
|
|
4228
|
-
init_createSchema();
|
|
4229
|
-
},
|
|
4230
|
-
});
|
|
4231
|
-
|
|
4232
|
-
// ../core/schemas/src/common/validation/enhanceSchema.ts
|
|
4233
|
-
var init_enhanceSchema = __esm({
|
|
4234
|
-
'../core/schemas/src/common/validation/enhanceSchema.ts'() {
|
|
4235
|
-
'use strict';
|
|
4236
|
-
},
|
|
4237
|
-
});
|
|
4238
|
-
|
|
4239
|
-
// ../core/schemas/src/common/validation/validateDates.ts
|
|
4240
|
-
var init_validateDates = __esm({
|
|
4241
|
-
'../core/schemas/src/common/validation/validateDates.ts'() {
|
|
4242
|
-
'use strict';
|
|
4243
|
-
init_server();
|
|
4244
|
-
},
|
|
4245
|
-
});
|
|
4246
|
-
|
|
4247
|
-
// ../core/schemas/src/common/validation/validateUniqueFields.ts
|
|
4248
|
-
var init_validateUniqueFields = __esm({
|
|
4249
|
-
'../core/schemas/src/common/validation/validateUniqueFields.ts'() {
|
|
4250
|
-
'use strict';
|
|
4251
|
-
init_server();
|
|
4252
|
-
},
|
|
4253
|
-
});
|
|
4254
|
-
|
|
4255
|
-
// ../core/schemas/src/common/validation/validateDocument.ts
|
|
4256
|
-
var init_validateDocument = __esm({
|
|
4257
|
-
'../core/schemas/src/common/validation/validateDocument.ts'() {
|
|
4258
|
-
'use strict';
|
|
4259
|
-
init_validateDates();
|
|
4260
|
-
init_validateUniqueFields();
|
|
4261
|
-
},
|
|
4262
|
-
});
|
|
4263
|
-
|
|
4264
|
-
// ../core/schemas/src/common/validation/index.ts
|
|
4265
|
-
var init_validation2 = __esm({
|
|
4266
|
-
'../core/schemas/src/common/validation/index.ts'() {
|
|
4267
|
-
'use strict';
|
|
4268
|
-
init_enhanceSchema();
|
|
4269
|
-
init_getSchemaType();
|
|
4270
|
-
init_validateDates();
|
|
4271
|
-
init_validateDocument();
|
|
4272
|
-
init_validateUniqueFields();
|
|
4273
|
-
},
|
|
4274
|
-
});
|
|
4275
|
-
|
|
4276
|
-
// ../core/schemas/src/common/utils.ts
|
|
4277
|
-
var init_utils2 = __esm({
|
|
4278
|
-
'../core/schemas/src/common/utils.ts'() {
|
|
4279
|
-
'use strict';
|
|
4280
|
-
init_server();
|
|
4281
|
-
},
|
|
4282
|
-
});
|
|
4283
|
-
|
|
4284
|
-
// ../core/schemas/src/common/defineEntity.ts
|
|
4285
|
-
var init_defineEntity = __esm({
|
|
4286
|
-
'../core/schemas/src/common/defineEntity.ts'() {
|
|
4287
|
-
'use strict';
|
|
4288
|
-
init_src();
|
|
4289
|
-
init_server();
|
|
4290
|
-
init_visibility();
|
|
4291
|
-
},
|
|
4292
|
-
});
|
|
4293
|
-
|
|
4294
|
-
// ../core/schemas/src/common/optionHelpers.ts
|
|
4295
|
-
var init_optionHelpers = __esm({
|
|
4296
|
-
'../core/schemas/src/common/optionHelpers.ts'() {
|
|
4297
|
-
'use strict';
|
|
4298
|
-
},
|
|
4299
|
-
});
|
|
4300
|
-
|
|
4301
|
-
// ../core/schemas/src/common/scopeProvider.ts
|
|
4302
|
-
var init_scopeProvider = __esm({
|
|
4303
|
-
'../core/schemas/src/common/scopeProvider.ts'() {
|
|
4304
|
-
'use strict';
|
|
4305
|
-
},
|
|
4306
|
-
});
|
|
4307
|
-
|
|
4308
4042
|
// ../core/schemas/src/common/index.ts
|
|
4309
4043
|
var init_common3 = __esm({
|
|
4310
4044
|
'../core/schemas/src/common/index.ts'() {
|
|
@@ -4314,26 +4048,22 @@ var init_common3 = __esm({
|
|
|
4314
4048
|
init_visibility();
|
|
4315
4049
|
init_defineEntity();
|
|
4316
4050
|
init_createSchema();
|
|
4317
|
-
init_optionHelpers();
|
|
4318
|
-
init_scopeProvider();
|
|
4319
4051
|
},
|
|
4320
4052
|
});
|
|
4321
4053
|
|
|
4322
|
-
// ../core/schemas/src/index.ts
|
|
4323
|
-
var
|
|
4324
|
-
'../core/schemas/src/index.ts'() {
|
|
4325
|
-
'use strict';
|
|
4326
|
-
init_client();
|
|
4054
|
+
// ../core/schemas/src/server/index.ts
|
|
4055
|
+
var init_server2 = __esm({
|
|
4056
|
+
'../core/schemas/src/server/index.ts'() {
|
|
4327
4057
|
init_common3();
|
|
4328
4058
|
},
|
|
4329
4059
|
});
|
|
4330
4060
|
|
|
4331
4061
|
// ../core/server.ts
|
|
4332
|
-
var
|
|
4062
|
+
var init_server3 = __esm({
|
|
4333
4063
|
'../core/server.ts'() {
|
|
4334
4064
|
init_server();
|
|
4335
4065
|
init_src();
|
|
4336
|
-
|
|
4066
|
+
init_server2();
|
|
4337
4067
|
init_server();
|
|
4338
4068
|
},
|
|
4339
4069
|
});
|
|
@@ -4422,7 +4152,7 @@ var getFirebaseAdminServices;
|
|
|
4422
4152
|
var init_init = __esm({
|
|
4423
4153
|
'../providers/firebase/src/server/init.ts'() {
|
|
4424
4154
|
'use strict';
|
|
4425
|
-
|
|
4155
|
+
init_server3();
|
|
4426
4156
|
__name(initializeFirebaseAdminServices, 'initializeFirebaseAdminServices');
|
|
4427
4157
|
getFirebaseAdminServices = createSingleton(initializeFirebaseAdminServices);
|
|
4428
4158
|
__name(initFirebaseAdmin, 'initFirebaseAdmin');
|
|
@@ -4438,7 +4168,7 @@ var serverImplementations, getServerAdmin, getServerFirestore, generateServerId;
|
|
|
4438
4168
|
var init_utils3 = __esm({
|
|
4439
4169
|
'../providers/firebase/src/server/utils.ts'() {
|
|
4440
4170
|
'use strict';
|
|
4441
|
-
|
|
4171
|
+
init_server3();
|
|
4442
4172
|
serverImplementations = {
|
|
4443
4173
|
async getServerAdmin() {
|
|
4444
4174
|
try {
|
|
@@ -4619,8 +4349,22 @@ function prepareForFirestore(data, removeFields = []) {
|
|
|
4619
4349
|
if (Array.isArray(data)) {
|
|
4620
4350
|
return data.map((item) => prepareForFirestore(item, removeFields));
|
|
4621
4351
|
}
|
|
4352
|
+
if (
|
|
4353
|
+
typeof data === 'string' &&
|
|
4354
|
+
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z$/.test(data)
|
|
4355
|
+
) {
|
|
4356
|
+
try {
|
|
4357
|
+
return toTimestamp(data);
|
|
4358
|
+
} catch (error) {
|
|
4359
|
+
return data;
|
|
4360
|
+
}
|
|
4361
|
+
}
|
|
4622
4362
|
if (data instanceof Date) {
|
|
4623
|
-
|
|
4363
|
+
try {
|
|
4364
|
+
return toTimestamp(data);
|
|
4365
|
+
} catch (error) {
|
|
4366
|
+
return data;
|
|
4367
|
+
}
|
|
4624
4368
|
}
|
|
4625
4369
|
if (typeof data === 'object' && data !== null) {
|
|
4626
4370
|
const prepared = {};
|
|
@@ -4656,7 +4400,7 @@ function createFirestorePartialUpdate(original, updated) {
|
|
|
4656
4400
|
var init_transform = __esm({
|
|
4657
4401
|
'../providers/firebase/src/shared/transform.ts'() {
|
|
4658
4402
|
'use strict';
|
|
4659
|
-
|
|
4403
|
+
init_server3();
|
|
4660
4404
|
__name(createTimestamp, 'createTimestamp');
|
|
4661
4405
|
__name(toTimestamp, 'toTimestamp');
|
|
4662
4406
|
__name(firestoreToISOString, 'firestoreToISOString');
|
|
@@ -4683,7 +4427,7 @@ var init_batch = __esm({
|
|
|
4683
4427
|
'../providers/firebase/src/server/batch.ts'() {
|
|
4684
4428
|
'use strict';
|
|
4685
4429
|
init_dist();
|
|
4686
|
-
|
|
4430
|
+
init_server3();
|
|
4687
4431
|
init_utils3();
|
|
4688
4432
|
init_transform();
|
|
4689
4433
|
isClient = typeof window !== 'undefined';
|
|
@@ -4962,7 +4706,7 @@ var isClient2, notAvailableInBrowser2, admin, getAdminFirestore, generateId;
|
|
|
4962
4706
|
var init_utils4 = __esm({
|
|
4963
4707
|
'../providers/firebase/src/shared/utils.ts'() {
|
|
4964
4708
|
'use strict';
|
|
4965
|
-
|
|
4709
|
+
init_server3();
|
|
4966
4710
|
isClient2 = typeof window !== 'undefined';
|
|
4967
4711
|
notAvailableInBrowser2 = /* @__PURE__ */ __name(
|
|
4968
4712
|
(fnName) => () => {
|
|
@@ -5145,7 +4889,7 @@ async function saveSubscriptionFromStripeEvent(
|
|
|
5145
4889
|
var init_subscription = __esm({
|
|
5146
4890
|
'../providers/firebase/src/server/subscription.ts'() {
|
|
5147
4891
|
'use strict';
|
|
5148
|
-
|
|
4892
|
+
init_server3();
|
|
5149
4893
|
init_utils3();
|
|
5150
4894
|
init_transform();
|
|
5151
4895
|
init_utils4();
|
|
@@ -5305,7 +5049,7 @@ var validatorRegistry;
|
|
|
5305
5049
|
var init_uniqueness = __esm({
|
|
5306
5050
|
'../providers/firebase/src/server/uniqueness.ts'() {
|
|
5307
5051
|
'use strict';
|
|
5308
|
-
|
|
5052
|
+
init_server3();
|
|
5309
5053
|
init_utils3();
|
|
5310
5054
|
validatorRegistry = {};
|
|
5311
5055
|
__name(
|
|
@@ -5369,7 +5113,7 @@ var init_validation3 = __esm({
|
|
|
5369
5113
|
'../providers/firebase/src/server/validation.ts'() {
|
|
5370
5114
|
'use strict';
|
|
5371
5115
|
init_dist();
|
|
5372
|
-
|
|
5116
|
+
init_server3();
|
|
5373
5117
|
init_uniqueness();
|
|
5374
5118
|
init_uniqueness();
|
|
5375
5119
|
__name(validateFirestoreDocument, 'validateFirestoreDocument');
|
|
@@ -5421,7 +5165,7 @@ __export(server_exports2, {
|
|
|
5421
5165
|
validateUniqueness: () => validateUniqueness,
|
|
5422
5166
|
});
|
|
5423
5167
|
import { FieldValue, Query, Timestamp } from 'firebase-admin/firestore';
|
|
5424
|
-
var
|
|
5168
|
+
var init_server4 = __esm({
|
|
5425
5169
|
'../providers/firebase/src/server/index.ts'() {
|
|
5426
5170
|
'use strict';
|
|
5427
5171
|
init_init();
|
|
@@ -5434,504 +5178,18 @@ var init_server3 = __esm({
|
|
|
5434
5178
|
},
|
|
5435
5179
|
});
|
|
5436
5180
|
|
|
5437
|
-
// src/shared/utils/internal/rateLimiter.ts
|
|
5438
|
-
var rateLimiter_exports = {};
|
|
5439
|
-
__export(rateLimiter_exports, {
|
|
5440
|
-
DEFAULT_RATE_LIMITS: () => DEFAULT_RATE_LIMITS,
|
|
5441
|
-
checkRateLimit: () => checkRateLimit,
|
|
5442
|
-
checkRateLimitWithFirestore: () => checkRateLimitWithFirestore,
|
|
5443
|
-
getRateLimitStatus: () => getRateLimitStatus,
|
|
5444
|
-
resetRateLimit: () => resetRateLimit,
|
|
5445
|
-
resetRateLimitInFirestore: () => resetRateLimitInFirestore,
|
|
5446
|
-
});
|
|
5447
|
-
import { logger } from 'firebase-functions/v2';
|
|
5448
|
-
async function checkRateLimit(key, config) {
|
|
5449
|
-
const now = Date.now();
|
|
5450
|
-
const entry = rateLimitStore.get(key);
|
|
5451
|
-
if (entry?.blockUntil && now < entry.blockUntil) {
|
|
5452
|
-
return {
|
|
5453
|
-
allowed: false,
|
|
5454
|
-
remaining: 0,
|
|
5455
|
-
resetAt: new Date(entry.blockUntil),
|
|
5456
|
-
blockRemainingSeconds: Math.ceil((entry.blockUntil - now) / 1e3),
|
|
5457
|
-
};
|
|
5458
|
-
}
|
|
5459
|
-
if (entry && now >= entry.windowStart + config.windowMs) {
|
|
5460
|
-
rateLimitStore.delete(key);
|
|
5461
|
-
}
|
|
5462
|
-
const currentEntry = rateLimitStore.get(key) || {
|
|
5463
|
-
attempts: 0,
|
|
5464
|
-
windowStart: now,
|
|
5465
|
-
blockUntil: null,
|
|
5466
|
-
};
|
|
5467
|
-
if (currentEntry.attempts >= config.maxAttempts) {
|
|
5468
|
-
currentEntry.blockUntil = now + config.blockDurationMs;
|
|
5469
|
-
rateLimitStore.set(key, currentEntry);
|
|
5470
|
-
logger.warn('Rate limit exceeded', {
|
|
5471
|
-
key,
|
|
5472
|
-
attempts: currentEntry.attempts,
|
|
5473
|
-
blockUntil: new Date(currentEntry.blockUntil),
|
|
5474
|
-
});
|
|
5475
|
-
return {
|
|
5476
|
-
allowed: false,
|
|
5477
|
-
remaining: 0,
|
|
5478
|
-
resetAt: new Date(currentEntry.blockUntil),
|
|
5479
|
-
blockRemainingSeconds: Math.ceil(config.blockDurationMs / 1e3),
|
|
5480
|
-
};
|
|
5481
|
-
}
|
|
5482
|
-
currentEntry.attempts += 1;
|
|
5483
|
-
rateLimitStore.set(key, currentEntry);
|
|
5484
|
-
return {
|
|
5485
|
-
allowed: true,
|
|
5486
|
-
remaining: config.maxAttempts - currentEntry.attempts,
|
|
5487
|
-
resetAt: new Date(currentEntry.windowStart + config.windowMs),
|
|
5488
|
-
blockRemainingSeconds: null,
|
|
5489
|
-
};
|
|
5490
|
-
}
|
|
5491
|
-
async function checkRateLimitWithFirestore(key, config) {
|
|
5492
|
-
const db = getFirebaseAdminFirestore();
|
|
5493
|
-
const rateLimitRef = db.collection('rateLimits').doc(key);
|
|
5494
|
-
try {
|
|
5495
|
-
const now = Date.now();
|
|
5496
|
-
const doc = await rateLimitRef.get();
|
|
5497
|
-
if (!doc.exists) {
|
|
5498
|
-
await rateLimitRef.set({
|
|
5499
|
-
attempts: 1,
|
|
5500
|
-
windowStart: now,
|
|
5501
|
-
blockUntil: null,
|
|
5502
|
-
lastUpdated: now,
|
|
5503
|
-
});
|
|
5504
|
-
return {
|
|
5505
|
-
allowed: true,
|
|
5506
|
-
remaining: config.maxAttempts - 1,
|
|
5507
|
-
resetAt: new Date(now + config.windowMs),
|
|
5508
|
-
blockRemainingSeconds: null,
|
|
5509
|
-
};
|
|
5510
|
-
}
|
|
5511
|
-
const data = doc.data();
|
|
5512
|
-
if (data.blockUntil && now < data.blockUntil) {
|
|
5513
|
-
return {
|
|
5514
|
-
allowed: false,
|
|
5515
|
-
remaining: 0,
|
|
5516
|
-
resetAt: new Date(data.blockUntil),
|
|
5517
|
-
blockRemainingSeconds: Math.ceil((data.blockUntil - now) / 1e3),
|
|
5518
|
-
};
|
|
5519
|
-
}
|
|
5520
|
-
if (now >= data.windowStart + config.windowMs) {
|
|
5521
|
-
await rateLimitRef.set({
|
|
5522
|
-
attempts: 1,
|
|
5523
|
-
windowStart: now,
|
|
5524
|
-
blockUntil: null,
|
|
5525
|
-
lastUpdated: now,
|
|
5526
|
-
});
|
|
5527
|
-
return {
|
|
5528
|
-
allowed: true,
|
|
5529
|
-
remaining: config.maxAttempts - 1,
|
|
5530
|
-
resetAt: new Date(now + config.windowMs),
|
|
5531
|
-
blockRemainingSeconds: null,
|
|
5532
|
-
};
|
|
5533
|
-
}
|
|
5534
|
-
if (data.attempts >= config.maxAttempts) {
|
|
5535
|
-
const blockUntil = now + config.blockDurationMs;
|
|
5536
|
-
await rateLimitRef.update({
|
|
5537
|
-
blockUntil,
|
|
5538
|
-
lastUpdated: now,
|
|
5539
|
-
});
|
|
5540
|
-
logger.warn('Rate limit exceeded (Firestore)', {
|
|
5541
|
-
key,
|
|
5542
|
-
attempts: data.attempts,
|
|
5543
|
-
blockUntil: new Date(blockUntil),
|
|
5544
|
-
});
|
|
5545
|
-
return {
|
|
5546
|
-
allowed: false,
|
|
5547
|
-
remaining: 0,
|
|
5548
|
-
resetAt: new Date(blockUntil),
|
|
5549
|
-
blockRemainingSeconds: Math.ceil(config.blockDurationMs / 1e3),
|
|
5550
|
-
};
|
|
5551
|
-
}
|
|
5552
|
-
await rateLimitRef.update({
|
|
5553
|
-
attempts: data.attempts + 1,
|
|
5554
|
-
lastUpdated: now,
|
|
5555
|
-
});
|
|
5556
|
-
return {
|
|
5557
|
-
allowed: true,
|
|
5558
|
-
remaining: config.maxAttempts - (data.attempts + 1),
|
|
5559
|
-
resetAt: new Date(data.windowStart + config.windowMs),
|
|
5560
|
-
blockRemainingSeconds: null,
|
|
5561
|
-
};
|
|
5562
|
-
} catch (error) {
|
|
5563
|
-
logger.error('Rate limit check failed', {
|
|
5564
|
-
key,
|
|
5565
|
-
error: error instanceof Error ? error.message : String(error),
|
|
5566
|
-
});
|
|
5567
|
-
return {
|
|
5568
|
-
allowed: true,
|
|
5569
|
-
remaining: config.maxAttempts,
|
|
5570
|
-
resetAt: null,
|
|
5571
|
-
blockRemainingSeconds: null,
|
|
5572
|
-
};
|
|
5573
|
-
}
|
|
5574
|
-
}
|
|
5575
|
-
function resetRateLimit(key) {
|
|
5576
|
-
rateLimitStore.delete(key);
|
|
5577
|
-
logger.info('Rate limit reset', { key });
|
|
5578
|
-
}
|
|
5579
|
-
async function resetRateLimitInFirestore(key) {
|
|
5580
|
-
const db = getFirebaseAdminFirestore();
|
|
5581
|
-
const rateLimitRef = db.collection('rateLimits').doc(key);
|
|
5582
|
-
try {
|
|
5583
|
-
await rateLimitRef.delete();
|
|
5584
|
-
logger.info('Rate limit reset (Firestore)', { key });
|
|
5585
|
-
} catch (error) {
|
|
5586
|
-
logger.error('Failed to reset rate limit', {
|
|
5587
|
-
key,
|
|
5588
|
-
error: error instanceof Error ? error.message : String(error),
|
|
5589
|
-
});
|
|
5590
|
-
}
|
|
5591
|
-
}
|
|
5592
|
-
function getRateLimitStatus(key, config) {
|
|
5593
|
-
const now = Date.now();
|
|
5594
|
-
const entry = rateLimitStore.get(key);
|
|
5595
|
-
if (!entry) {
|
|
5596
|
-
return {
|
|
5597
|
-
allowed: true,
|
|
5598
|
-
remaining: config.maxAttempts,
|
|
5599
|
-
resetAt: null,
|
|
5600
|
-
blockRemainingSeconds: null,
|
|
5601
|
-
};
|
|
5602
|
-
}
|
|
5603
|
-
if (entry.blockUntil && now < entry.blockUntil) {
|
|
5604
|
-
return {
|
|
5605
|
-
allowed: false,
|
|
5606
|
-
remaining: 0,
|
|
5607
|
-
resetAt: new Date(entry.blockUntil),
|
|
5608
|
-
blockRemainingSeconds: Math.ceil((entry.blockUntil - now) / 1e3),
|
|
5609
|
-
};
|
|
5610
|
-
}
|
|
5611
|
-
if (now >= entry.windowStart + config.windowMs) {
|
|
5612
|
-
return {
|
|
5613
|
-
allowed: true,
|
|
5614
|
-
remaining: config.maxAttempts,
|
|
5615
|
-
resetAt: null,
|
|
5616
|
-
blockRemainingSeconds: null,
|
|
5617
|
-
};
|
|
5618
|
-
}
|
|
5619
|
-
return {
|
|
5620
|
-
allowed: entry.attempts < config.maxAttempts,
|
|
5621
|
-
remaining: Math.max(0, config.maxAttempts - entry.attempts),
|
|
5622
|
-
resetAt: new Date(entry.windowStart + config.windowMs),
|
|
5623
|
-
blockRemainingSeconds: null,
|
|
5624
|
-
};
|
|
5625
|
-
}
|
|
5626
|
-
var rateLimitStore, DEFAULT_RATE_LIMITS;
|
|
5627
|
-
var init_rateLimiter2 = __esm({
|
|
5628
|
-
'src/shared/utils/internal/rateLimiter.ts'() {
|
|
5629
|
-
'use strict';
|
|
5630
|
-
init_server3();
|
|
5631
|
-
rateLimitStore = /* @__PURE__ */ new Map();
|
|
5632
|
-
__name(checkRateLimit, 'checkRateLimit');
|
|
5633
|
-
__name(checkRateLimitWithFirestore, 'checkRateLimitWithFirestore');
|
|
5634
|
-
__name(resetRateLimit, 'resetRateLimit');
|
|
5635
|
-
__name(resetRateLimitInFirestore, 'resetRateLimitInFirestore');
|
|
5636
|
-
__name(getRateLimitStatus, 'getRateLimitStatus');
|
|
5637
|
-
DEFAULT_RATE_LIMITS = {
|
|
5638
|
-
checkout: {
|
|
5639
|
-
maxAttempts: 5,
|
|
5640
|
-
windowMs: 60 * 1e3,
|
|
5641
|
-
// 1 minute
|
|
5642
|
-
blockDurationMs: 5 * 60 * 1e3,
|
|
5643
|
-
// 5 minutes
|
|
5644
|
-
},
|
|
5645
|
-
webhook: {
|
|
5646
|
-
maxAttempts: 100,
|
|
5647
|
-
windowMs: 60 * 1e3,
|
|
5648
|
-
// 1 minute
|
|
5649
|
-
blockDurationMs: 60 * 1e3,
|
|
5650
|
-
// 1 minute
|
|
5651
|
-
},
|
|
5652
|
-
auth: {
|
|
5653
|
-
maxAttempts: 10,
|
|
5654
|
-
windowMs: 60 * 1e3,
|
|
5655
|
-
// 1 minute
|
|
5656
|
-
blockDurationMs: 5 * 60 * 1e3,
|
|
5657
|
-
// 5 minutes
|
|
5658
|
-
},
|
|
5659
|
-
api: {
|
|
5660
|
-
maxAttempts: 100,
|
|
5661
|
-
windowMs: 60 * 1e3,
|
|
5662
|
-
// 1 minute
|
|
5663
|
-
blockDurationMs: 60 * 1e3,
|
|
5664
|
-
// 1 minute
|
|
5665
|
-
},
|
|
5666
|
-
};
|
|
5667
|
-
},
|
|
5668
|
-
});
|
|
5669
|
-
|
|
5670
|
-
// src/shared/utils/internal/monitoring.ts
|
|
5671
|
-
var monitoring_exports = {};
|
|
5672
|
-
__export(monitoring_exports, {
|
|
5673
|
-
checkPaymentFailureRate: () => checkPaymentFailureRate,
|
|
5674
|
-
checkPaymentVolume: () => checkPaymentVolume,
|
|
5675
|
-
cleanupOldMetrics: () => cleanupOldMetrics,
|
|
5676
|
-
getPaymentMetricsSummary: () => getPaymentMetricsSummary,
|
|
5677
|
-
recordPaymentMetrics: () => recordPaymentMetrics,
|
|
5678
|
-
});
|
|
5679
|
-
import { logger as logger2 } from 'firebase-functions/v2';
|
|
5680
|
-
async function recordPaymentMetrics(metrics) {
|
|
5681
|
-
try {
|
|
5682
|
-
const db = getFirebaseAdminFirestore();
|
|
5683
|
-
const metricsRef = db.collection('payment_metrics').doc();
|
|
5684
|
-
await metricsRef.set({
|
|
5685
|
-
...metrics,
|
|
5686
|
-
recordedAt: /* @__PURE__ */ new Date().toISOString(),
|
|
5687
|
-
});
|
|
5688
|
-
logger2.info('Payment metrics recorded', {
|
|
5689
|
-
operation: metrics.operation,
|
|
5690
|
-
status: metrics.status,
|
|
5691
|
-
userId: metrics.userId,
|
|
5692
|
-
});
|
|
5693
|
-
} catch (error) {
|
|
5694
|
-
logger2.error('Failed to record payment metrics', {
|
|
5695
|
-
error: error instanceof Error ? error.message : String(error),
|
|
5696
|
-
metrics,
|
|
5697
|
-
});
|
|
5698
|
-
}
|
|
5699
|
-
}
|
|
5700
|
-
async function checkPaymentFailureRate(timeWindowHours = 24) {
|
|
5701
|
-
try {
|
|
5702
|
-
const db = getFirebaseAdminFirestore();
|
|
5703
|
-
const cutoffTime = /* @__PURE__ */ new Date();
|
|
5704
|
-
cutoffTime.setHours(cutoffTime.getHours() - timeWindowHours);
|
|
5705
|
-
const metricsRef = db.collection('payment_metrics');
|
|
5706
|
-
const recentMetrics = await metricsRef
|
|
5707
|
-
.where('timestamp', '>=', cutoffTime.toISOString())
|
|
5708
|
-
.get();
|
|
5709
|
-
if (recentMetrics.empty) {
|
|
5710
|
-
return { failureRate: 0, shouldAlert: false };
|
|
5711
|
-
}
|
|
5712
|
-
const totalPayments = recentMetrics.size;
|
|
5713
|
-
const failedPayments = recentMetrics.docs.filter(
|
|
5714
|
-
(doc) => doc.data().status === 'failed'
|
|
5715
|
-
).length;
|
|
5716
|
-
const failureRate = (failedPayments / totalPayments) * 100;
|
|
5717
|
-
const shouldAlert = failureRate > 10;
|
|
5718
|
-
if (shouldAlert) {
|
|
5719
|
-
await triggerPaymentFailureAlert(
|
|
5720
|
-
failureRate,
|
|
5721
|
-
totalPayments,
|
|
5722
|
-
failedPayments
|
|
5723
|
-
);
|
|
5724
|
-
}
|
|
5725
|
-
return { failureRate, shouldAlert };
|
|
5726
|
-
} catch (error) {
|
|
5727
|
-
logger2.error('Failed to check payment failure rate', {
|
|
5728
|
-
error: error instanceof Error ? error.message : String(error),
|
|
5729
|
-
});
|
|
5730
|
-
return { failureRate: 0, shouldAlert: false };
|
|
5731
|
-
}
|
|
5732
|
-
}
|
|
5733
|
-
async function checkPaymentVolume(volumeThreshold = 1e4) {
|
|
5734
|
-
try {
|
|
5735
|
-
const db = getFirebaseAdminFirestore();
|
|
5736
|
-
const today = /* @__PURE__ */ new Date();
|
|
5737
|
-
today.setHours(0, 0, 0, 0);
|
|
5738
|
-
const tomorrow = new Date(today);
|
|
5739
|
-
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
5740
|
-
const metricsRef = db.collection('payment_metrics');
|
|
5741
|
-
const todayMetrics = await metricsRef
|
|
5742
|
-
.where('timestamp', '>=', today.toISOString())
|
|
5743
|
-
.where('timestamp', '<', tomorrow.toISOString())
|
|
5744
|
-
.where('status', '==', 'success')
|
|
5745
|
-
.get();
|
|
5746
|
-
let totalVolume = 0;
|
|
5747
|
-
todayMetrics.docs.forEach((doc) => {
|
|
5748
|
-
const data = doc.data();
|
|
5749
|
-
if (data.amount && data.currency === 'usd') {
|
|
5750
|
-
totalVolume += data.amount / 100;
|
|
5751
|
-
}
|
|
5752
|
-
});
|
|
5753
|
-
const shouldAlert = totalVolume > volumeThreshold;
|
|
5754
|
-
if (shouldAlert) {
|
|
5755
|
-
await triggerHighVolumeAlert(totalVolume, volumeThreshold);
|
|
5756
|
-
}
|
|
5757
|
-
return { totalVolume, shouldAlert };
|
|
5758
|
-
} catch (error) {
|
|
5759
|
-
logger2.error('Failed to check payment volume', {
|
|
5760
|
-
error: error instanceof Error ? error.message : String(error),
|
|
5761
|
-
});
|
|
5762
|
-
return { totalVolume: 0, shouldAlert: false };
|
|
5763
|
-
}
|
|
5764
|
-
}
|
|
5765
|
-
async function triggerPaymentFailureAlert(
|
|
5766
|
-
failureRate,
|
|
5767
|
-
totalPayments,
|
|
5768
|
-
failedPayments
|
|
5769
|
-
) {
|
|
5770
|
-
try {
|
|
5771
|
-
const db = getFirebaseAdminFirestore();
|
|
5772
|
-
const alertRef = db.collection('payment_alerts').doc();
|
|
5773
|
-
await alertRef.set({
|
|
5774
|
-
type: 'payment_failure_rate',
|
|
5775
|
-
severity: 'high',
|
|
5776
|
-
message: `Payment failure rate is ${failureRate.toFixed(2)}% (${failedPayments}/${totalPayments} payments failed)`,
|
|
5777
|
-
data: {
|
|
5778
|
-
failureRate,
|
|
5779
|
-
totalPayments,
|
|
5780
|
-
failedPayments,
|
|
5781
|
-
},
|
|
5782
|
-
triggeredAt: /* @__PURE__ */ new Date().toISOString(),
|
|
5783
|
-
status: 'active',
|
|
5784
|
-
});
|
|
5785
|
-
logger2.error('PAYMENT FAILURE ALERT TRIGGERED', {
|
|
5786
|
-
failureRate,
|
|
5787
|
-
totalPayments,
|
|
5788
|
-
failedPayments,
|
|
5789
|
-
});
|
|
5790
|
-
} catch (error) {
|
|
5791
|
-
logger2.error('Failed to trigger payment failure alert', {
|
|
5792
|
-
error: error instanceof Error ? error.message : String(error),
|
|
5793
|
-
});
|
|
5794
|
-
}
|
|
5795
|
-
}
|
|
5796
|
-
async function triggerHighVolumeAlert(totalVolume, threshold) {
|
|
5797
|
-
try {
|
|
5798
|
-
const db = getFirebaseAdminFirestore();
|
|
5799
|
-
const alertRef = db.collection('payment_alerts').doc();
|
|
5800
|
-
await alertRef.set({
|
|
5801
|
-
type: 'high_payment_volume',
|
|
5802
|
-
severity: 'medium',
|
|
5803
|
-
message: `Daily payment volume exceeded threshold: $${totalVolume.toFixed(2)} (threshold: $${threshold})`,
|
|
5804
|
-
data: {
|
|
5805
|
-
totalVolume,
|
|
5806
|
-
threshold,
|
|
5807
|
-
},
|
|
5808
|
-
triggeredAt: /* @__PURE__ */ new Date().toISOString(),
|
|
5809
|
-
status: 'active',
|
|
5810
|
-
});
|
|
5811
|
-
logger2.warn('HIGH PAYMENT VOLUME ALERT TRIGGERED', {
|
|
5812
|
-
totalVolume,
|
|
5813
|
-
threshold,
|
|
5814
|
-
});
|
|
5815
|
-
} catch (error) {
|
|
5816
|
-
logger2.error('Failed to trigger high volume alert', {
|
|
5817
|
-
error: error instanceof Error ? error.message : String(error),
|
|
5818
|
-
});
|
|
5819
|
-
}
|
|
5820
|
-
}
|
|
5821
|
-
async function getPaymentMetricsSummary(startDate, endDate) {
|
|
5822
|
-
try {
|
|
5823
|
-
const db = getFirebaseAdminFirestore();
|
|
5824
|
-
const metricsRef = db.collection('payment_metrics');
|
|
5825
|
-
const metrics = await metricsRef
|
|
5826
|
-
.where('timestamp', '>=', startDate.toISOString())
|
|
5827
|
-
.where('timestamp', '<=', endDate.toISOString())
|
|
5828
|
-
.get();
|
|
5829
|
-
let totalPayments = 0;
|
|
5830
|
-
let successfulPayments = 0;
|
|
5831
|
-
let failedPayments = 0;
|
|
5832
|
-
let totalVolume = 0;
|
|
5833
|
-
metrics.docs.forEach((doc) => {
|
|
5834
|
-
const data = doc.data();
|
|
5835
|
-
totalPayments++;
|
|
5836
|
-
if (data.status === 'success') {
|
|
5837
|
-
successfulPayments++;
|
|
5838
|
-
if (data.amount && data.currency === 'usd') {
|
|
5839
|
-
totalVolume += data.amount / 100;
|
|
5840
|
-
}
|
|
5841
|
-
} else if (data.status === 'failed') {
|
|
5842
|
-
failedPayments++;
|
|
5843
|
-
}
|
|
5844
|
-
});
|
|
5845
|
-
const averageAmount =
|
|
5846
|
-
successfulPayments > 0 ? totalVolume / successfulPayments : 0;
|
|
5847
|
-
return {
|
|
5848
|
-
totalPayments,
|
|
5849
|
-
successfulPayments,
|
|
5850
|
-
failedPayments,
|
|
5851
|
-
totalVolume,
|
|
5852
|
-
averageAmount,
|
|
5853
|
-
};
|
|
5854
|
-
} catch (error) {
|
|
5855
|
-
logger2.error('Failed to get payment metrics summary', {
|
|
5856
|
-
error: error instanceof Error ? error.message : String(error),
|
|
5857
|
-
});
|
|
5858
|
-
return {
|
|
5859
|
-
totalPayments: 0,
|
|
5860
|
-
successfulPayments: 0,
|
|
5861
|
-
failedPayments: 0,
|
|
5862
|
-
totalVolume: 0,
|
|
5863
|
-
averageAmount: 0,
|
|
5864
|
-
};
|
|
5865
|
-
}
|
|
5866
|
-
}
|
|
5867
|
-
async function cleanupOldMetrics(
|
|
5868
|
-
metricsRetentionDays = 90,
|
|
5869
|
-
alertsRetentionDays = 30
|
|
5870
|
-
) {
|
|
5871
|
-
try {
|
|
5872
|
-
const db = getFirebaseAdminFirestore();
|
|
5873
|
-
const now = /* @__PURE__ */ new Date();
|
|
5874
|
-
const metricsCutoff = new Date(now);
|
|
5875
|
-
metricsCutoff.setDate(metricsCutoff.getDate() - metricsRetentionDays);
|
|
5876
|
-
const oldMetrics = await db
|
|
5877
|
-
.collection('payment_metrics')
|
|
5878
|
-
.where('recordedAt', '<', metricsCutoff.toISOString())
|
|
5879
|
-
.limit(500)
|
|
5880
|
-
.get();
|
|
5881
|
-
if (!oldMetrics.empty) {
|
|
5882
|
-
const batch = db.batch();
|
|
5883
|
-
oldMetrics.docs.forEach((doc) => batch.delete(doc.ref));
|
|
5884
|
-
await batch.commit();
|
|
5885
|
-
}
|
|
5886
|
-
const alertsCutoff = new Date(now);
|
|
5887
|
-
alertsCutoff.setDate(alertsCutoff.getDate() - alertsRetentionDays);
|
|
5888
|
-
const oldAlerts = await db
|
|
5889
|
-
.collection('payment_alerts')
|
|
5890
|
-
.where('triggeredAt', '<', alertsCutoff.toISOString())
|
|
5891
|
-
.limit(500)
|
|
5892
|
-
.get();
|
|
5893
|
-
if (!oldAlerts.empty) {
|
|
5894
|
-
const batch = db.batch();
|
|
5895
|
-
oldAlerts.docs.forEach((doc) => batch.delete(doc.ref));
|
|
5896
|
-
await batch.commit();
|
|
5897
|
-
}
|
|
5898
|
-
logger2.info('Payment metrics cleanup completed', {
|
|
5899
|
-
deletedMetrics: oldMetrics.size,
|
|
5900
|
-
deletedAlerts: oldAlerts.size,
|
|
5901
|
-
});
|
|
5902
|
-
} catch (error) {
|
|
5903
|
-
logger2.error('Payment metrics cleanup failed', {
|
|
5904
|
-
error: error instanceof Error ? error.message : String(error),
|
|
5905
|
-
});
|
|
5906
|
-
}
|
|
5907
|
-
}
|
|
5908
|
-
var init_monitoring = __esm({
|
|
5909
|
-
'src/shared/utils/internal/monitoring.ts'() {
|
|
5910
|
-
'use strict';
|
|
5911
|
-
init_server3();
|
|
5912
|
-
__name(recordPaymentMetrics, 'recordPaymentMetrics');
|
|
5913
|
-
__name(checkPaymentFailureRate, 'checkPaymentFailureRate');
|
|
5914
|
-
__name(checkPaymentVolume, 'checkPaymentVolume');
|
|
5915
|
-
__name(triggerPaymentFailureAlert, 'triggerPaymentFailureAlert');
|
|
5916
|
-
__name(triggerHighVolumeAlert, 'triggerHighVolumeAlert');
|
|
5917
|
-
__name(getPaymentMetricsSummary, 'getPaymentMetricsSummary');
|
|
5918
|
-
__name(cleanupOldMetrics, 'cleanupOldMetrics');
|
|
5919
|
-
},
|
|
5920
|
-
});
|
|
5921
|
-
|
|
5922
5181
|
// src/firebase/auth/getCustomClaims.ts
|
|
5182
|
+
init_server4();
|
|
5923
5183
|
init_dist();
|
|
5924
|
-
init_server3();
|
|
5925
5184
|
|
|
5926
5185
|
// src/firebase/baseFunction.ts
|
|
5927
5186
|
init_dist();
|
|
5928
|
-
init_server2();
|
|
5929
5187
|
import { logger as logger3 } from 'firebase-functions/v2';
|
|
5930
5188
|
import { onCall } from 'firebase-functions/v2/https';
|
|
5931
5189
|
|
|
5932
5190
|
// src/shared/errorHandling.ts
|
|
5191
|
+
init_server3();
|
|
5933
5192
|
import { HttpsError } from 'firebase-functions/v2/https';
|
|
5934
|
-
init_server2();
|
|
5935
5193
|
var DoNotDevError3 = class _DoNotDevError extends Error {
|
|
5936
5194
|
static {
|
|
5937
5195
|
__name(this, 'DoNotDevError');
|
|
@@ -6058,11 +5316,155 @@ function throwVercelError(code, message, details) {
|
|
|
6058
5316
|
error.details = details;
|
|
6059
5317
|
throw error;
|
|
6060
5318
|
}
|
|
6061
|
-
__name(throwVercelError, 'throwVercelError');
|
|
5319
|
+
__name(throwVercelError, 'throwVercelError');
|
|
5320
|
+
|
|
5321
|
+
// src/shared/utils/internal/monitoring.ts
|
|
5322
|
+
init_server4();
|
|
5323
|
+
import { logger } from 'firebase-functions/v2';
|
|
5324
|
+
async function recordPaymentMetrics(metrics) {
|
|
5325
|
+
try {
|
|
5326
|
+
const db = getFirebaseAdminFirestore();
|
|
5327
|
+
const metricsRef = db.collection('payment_metrics').doc();
|
|
5328
|
+
await metricsRef.set({
|
|
5329
|
+
...metrics,
|
|
5330
|
+
recordedAt: /* @__PURE__ */ new Date().toISOString(),
|
|
5331
|
+
});
|
|
5332
|
+
logger.info('Payment metrics recorded', {
|
|
5333
|
+
operation: metrics.operation,
|
|
5334
|
+
status: metrics.status,
|
|
5335
|
+
userId: metrics.userId,
|
|
5336
|
+
});
|
|
5337
|
+
} catch (error) {
|
|
5338
|
+
logger.error('Failed to record payment metrics', {
|
|
5339
|
+
error: error instanceof Error ? error.message : String(error),
|
|
5340
|
+
metrics,
|
|
5341
|
+
});
|
|
5342
|
+
}
|
|
5343
|
+
}
|
|
5344
|
+
__name(recordPaymentMetrics, 'recordPaymentMetrics');
|
|
5345
|
+
|
|
5346
|
+
// src/shared/utils/internal/rateLimiter.ts
|
|
5347
|
+
init_server4();
|
|
5348
|
+
import { logger as logger2 } from 'firebase-functions/v2';
|
|
5349
|
+
async function checkRateLimitWithFirestore(key, config) {
|
|
5350
|
+
const db = getFirebaseAdminFirestore();
|
|
5351
|
+
const rateLimitRef = db.collection('rateLimits').doc(key);
|
|
5352
|
+
try {
|
|
5353
|
+
const now = Date.now();
|
|
5354
|
+
const doc = await rateLimitRef.get();
|
|
5355
|
+
if (!doc.exists) {
|
|
5356
|
+
await rateLimitRef.set({
|
|
5357
|
+
attempts: 1,
|
|
5358
|
+
windowStart: now,
|
|
5359
|
+
blockUntil: null,
|
|
5360
|
+
lastUpdated: now,
|
|
5361
|
+
});
|
|
5362
|
+
return {
|
|
5363
|
+
allowed: true,
|
|
5364
|
+
remaining: config.maxAttempts - 1,
|
|
5365
|
+
resetAt: new Date(now + config.windowMs),
|
|
5366
|
+
blockRemainingSeconds: null,
|
|
5367
|
+
};
|
|
5368
|
+
}
|
|
5369
|
+
const data = doc.data();
|
|
5370
|
+
if (data.blockUntil && now < data.blockUntil) {
|
|
5371
|
+
return {
|
|
5372
|
+
allowed: false,
|
|
5373
|
+
remaining: 0,
|
|
5374
|
+
resetAt: new Date(data.blockUntil),
|
|
5375
|
+
blockRemainingSeconds: Math.ceil((data.blockUntil - now) / 1e3),
|
|
5376
|
+
};
|
|
5377
|
+
}
|
|
5378
|
+
if (now >= data.windowStart + config.windowMs) {
|
|
5379
|
+
await rateLimitRef.set({
|
|
5380
|
+
attempts: 1,
|
|
5381
|
+
windowStart: now,
|
|
5382
|
+
blockUntil: null,
|
|
5383
|
+
lastUpdated: now,
|
|
5384
|
+
});
|
|
5385
|
+
return {
|
|
5386
|
+
allowed: true,
|
|
5387
|
+
remaining: config.maxAttempts - 1,
|
|
5388
|
+
resetAt: new Date(now + config.windowMs),
|
|
5389
|
+
blockRemainingSeconds: null,
|
|
5390
|
+
};
|
|
5391
|
+
}
|
|
5392
|
+
if (data.attempts >= config.maxAttempts) {
|
|
5393
|
+
const blockUntil = now + config.blockDurationMs;
|
|
5394
|
+
await rateLimitRef.update({
|
|
5395
|
+
blockUntil,
|
|
5396
|
+
lastUpdated: now,
|
|
5397
|
+
});
|
|
5398
|
+
logger2.warn('Rate limit exceeded (Firestore)', {
|
|
5399
|
+
key,
|
|
5400
|
+
attempts: data.attempts,
|
|
5401
|
+
blockUntil: new Date(blockUntil),
|
|
5402
|
+
});
|
|
5403
|
+
return {
|
|
5404
|
+
allowed: false,
|
|
5405
|
+
remaining: 0,
|
|
5406
|
+
resetAt: new Date(blockUntil),
|
|
5407
|
+
blockRemainingSeconds: Math.ceil(config.blockDurationMs / 1e3),
|
|
5408
|
+
};
|
|
5409
|
+
}
|
|
5410
|
+
await rateLimitRef.update({
|
|
5411
|
+
attempts: data.attempts + 1,
|
|
5412
|
+
lastUpdated: now,
|
|
5413
|
+
});
|
|
5414
|
+
return {
|
|
5415
|
+
allowed: true,
|
|
5416
|
+
remaining: config.maxAttempts - (data.attempts + 1),
|
|
5417
|
+
resetAt: new Date(data.windowStart + config.windowMs),
|
|
5418
|
+
blockRemainingSeconds: null,
|
|
5419
|
+
};
|
|
5420
|
+
} catch (error) {
|
|
5421
|
+
logger2.error('Rate limit check failed', {
|
|
5422
|
+
key,
|
|
5423
|
+
error: error instanceof Error ? error.message : String(error),
|
|
5424
|
+
});
|
|
5425
|
+
return {
|
|
5426
|
+
allowed: true,
|
|
5427
|
+
remaining: config.maxAttempts,
|
|
5428
|
+
resetAt: null,
|
|
5429
|
+
blockRemainingSeconds: null,
|
|
5430
|
+
};
|
|
5431
|
+
}
|
|
5432
|
+
}
|
|
5433
|
+
__name(checkRateLimitWithFirestore, 'checkRateLimitWithFirestore');
|
|
5434
|
+
var DEFAULT_RATE_LIMITS = {
|
|
5435
|
+
checkout: {
|
|
5436
|
+
maxAttempts: 5,
|
|
5437
|
+
windowMs: 60 * 1e3,
|
|
5438
|
+
// 1 minute
|
|
5439
|
+
blockDurationMs: 5 * 60 * 1e3,
|
|
5440
|
+
// 5 minutes
|
|
5441
|
+
},
|
|
5442
|
+
webhook: {
|
|
5443
|
+
maxAttempts: 100,
|
|
5444
|
+
windowMs: 60 * 1e3,
|
|
5445
|
+
// 1 minute
|
|
5446
|
+
blockDurationMs: 60 * 1e3,
|
|
5447
|
+
// 1 minute
|
|
5448
|
+
},
|
|
5449
|
+
auth: {
|
|
5450
|
+
maxAttempts: 10,
|
|
5451
|
+
windowMs: 60 * 1e3,
|
|
5452
|
+
// 1 minute
|
|
5453
|
+
blockDurationMs: 5 * 60 * 1e3,
|
|
5454
|
+
// 5 minutes
|
|
5455
|
+
},
|
|
5456
|
+
api: {
|
|
5457
|
+
maxAttempts: 100,
|
|
5458
|
+
windowMs: 60 * 1e3,
|
|
5459
|
+
// 1 minute
|
|
5460
|
+
blockDurationMs: 60 * 1e3,
|
|
5461
|
+
// 1 minute
|
|
5462
|
+
},
|
|
5463
|
+
};
|
|
6062
5464
|
|
|
6063
5465
|
// src/shared/utils.ts
|
|
6064
|
-
init_server2();
|
|
6065
5466
|
init_server3();
|
|
5467
|
+
init_server4();
|
|
6066
5468
|
import Stripe from 'stripe';
|
|
6067
5469
|
var _stripe = null;
|
|
6068
5470
|
function initStripe(apiKey) {
|
|
@@ -6105,9 +5507,6 @@ function assertAuthenticated(auth) {
|
|
|
6105
5507
|
__name(assertAuthenticated, 'assertAuthenticated');
|
|
6106
5508
|
function getUserRole(auth) {
|
|
6107
5509
|
if (!auth?.uid) return 'guest';
|
|
6108
|
-
const role = auth.token?.role;
|
|
6109
|
-
if (role === 'super') return 'super';
|
|
6110
|
-
if (role === 'admin') return 'admin';
|
|
6111
5510
|
if (auth.token?.isSuper) return 'super';
|
|
6112
5511
|
if (auth.token?.isAdmin) return 'admin';
|
|
6113
5512
|
return 'user';
|
|
@@ -6120,6 +5519,13 @@ function validateStripeEnvironment() {
|
|
|
6120
5519
|
}
|
|
6121
5520
|
}
|
|
6122
5521
|
__name(validateStripeEnvironment, 'validateStripeEnvironment');
|
|
5522
|
+
function assertAdmin(uid) {
|
|
5523
|
+
if (!uid) {
|
|
5524
|
+
throw new Error('Authentication required');
|
|
5525
|
+
}
|
|
5526
|
+
return uid;
|
|
5527
|
+
}
|
|
5528
|
+
__name(assertAdmin, 'assertAdmin');
|
|
6123
5529
|
function validateDocument(data, schema) {
|
|
6124
5530
|
if (!data || typeof data !== 'object') {
|
|
6125
5531
|
throw new Error('Invalid document data');
|
|
@@ -6135,59 +5541,7 @@ function findReferences(collection, docId) {
|
|
|
6135
5541
|
__name(findReferences, 'findReferences');
|
|
6136
5542
|
|
|
6137
5543
|
// src/firebase/baseFunction.ts
|
|
6138
|
-
|
|
6139
|
-
var DEFAULT_RATE_LIMITS2 = null;
|
|
6140
|
-
var recordPaymentMetrics2 = null;
|
|
6141
|
-
async function loadRateLimiter() {
|
|
6142
|
-
if (!checkRateLimitWithFirestore2) {
|
|
6143
|
-
const mod = await Promise.resolve().then(
|
|
6144
|
-
() => (init_rateLimiter2(), rateLimiter_exports)
|
|
6145
|
-
);
|
|
6146
|
-
checkRateLimitWithFirestore2 = mod.checkRateLimitWithFirestore;
|
|
6147
|
-
DEFAULT_RATE_LIMITS2 = mod.DEFAULT_RATE_LIMITS;
|
|
6148
|
-
}
|
|
6149
|
-
return {
|
|
6150
|
-
checkRateLimitWithFirestore: checkRateLimitWithFirestore2,
|
|
6151
|
-
DEFAULT_RATE_LIMITS: DEFAULT_RATE_LIMITS2,
|
|
6152
|
-
};
|
|
6153
|
-
}
|
|
6154
|
-
__name(loadRateLimiter, 'loadRateLimiter');
|
|
6155
|
-
async function loadMonitoring() {
|
|
6156
|
-
if (!recordPaymentMetrics2) {
|
|
6157
|
-
const mod = await Promise.resolve().then(
|
|
6158
|
-
() => (init_monitoring(), monitoring_exports)
|
|
6159
|
-
);
|
|
6160
|
-
recordPaymentMetrics2 = mod.recordPaymentMetrics;
|
|
6161
|
-
}
|
|
6162
|
-
return recordPaymentMetrics2;
|
|
6163
|
-
}
|
|
6164
|
-
__name(loadMonitoring, 'loadMonitoring');
|
|
6165
|
-
function getClientIp(request) {
|
|
6166
|
-
const forwardedFor = request.rawRequest.headers['x-forwarded-for'];
|
|
6167
|
-
if (forwardedFor) {
|
|
6168
|
-
let ips;
|
|
6169
|
-
if (Array.isArray(forwardedFor)) {
|
|
6170
|
-
ips = forwardedFor.length > 0 ? forwardedFor[0] : void 0;
|
|
6171
|
-
} else {
|
|
6172
|
-
ips = forwardedFor;
|
|
6173
|
-
}
|
|
6174
|
-
if (ips && typeof ips === 'string') {
|
|
6175
|
-
const firstIp = ips.split(',')[0];
|
|
6176
|
-
return firstIp ? firstIp.trim() : 'unknown';
|
|
6177
|
-
}
|
|
6178
|
-
}
|
|
6179
|
-
const rawIp =
|
|
6180
|
-
request.rawRequest.ip || request.rawRequest.socket?.remoteAddress;
|
|
6181
|
-
return rawIp || 'unknown';
|
|
6182
|
-
}
|
|
6183
|
-
__name(getClientIp, 'getClientIp');
|
|
6184
|
-
function createBaseFunction(
|
|
6185
|
-
config,
|
|
6186
|
-
schema,
|
|
6187
|
-
operation,
|
|
6188
|
-
businessLogic,
|
|
6189
|
-
requiredRole = 'user'
|
|
6190
|
-
) {
|
|
5544
|
+
function createBaseFunction(config, schema, operation, businessLogic) {
|
|
6191
5545
|
if (!schema) {
|
|
6192
5546
|
const error = new Error(
|
|
6193
5547
|
`Schema is undefined for ${operation}. Ensure the schema is properly imported and exported.`
|
|
@@ -6258,95 +5612,69 @@ function createBaseFunction(
|
|
|
6258
5612
|
});
|
|
6259
5613
|
throw parseError;
|
|
6260
5614
|
}
|
|
6261
|
-
const
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
requiredRole,
|
|
6272
|
-
});
|
|
6273
|
-
throw new Error(
|
|
6274
|
-
`Access denied. Required role: ${requiredRole}, your role: ${userRole}`
|
|
6275
|
-
);
|
|
6276
|
-
}
|
|
6277
|
-
}
|
|
6278
|
-
if (process.env.ENABLE_RATE_LIMITING === 'true') {
|
|
6279
|
-
const {
|
|
6280
|
-
checkRateLimitWithFirestore: checkLimit,
|
|
6281
|
-
DEFAULT_RATE_LIMITS: limits,
|
|
6282
|
-
} = await loadRateLimiter();
|
|
6283
|
-
const rateLimitIdentifier =
|
|
6284
|
-
requiredRole === 'guest' && uid === 'guest'
|
|
6285
|
-
? `ip_${getClientIp(request)}`
|
|
6286
|
-
: `uid_${uid}`;
|
|
6287
|
-
const rateLimitKey = `${operation}_${rateLimitIdentifier}`;
|
|
6288
|
-
const rateLimitConfig = limits[operation] || limits.api;
|
|
6289
|
-
const rateLimitResult = await checkLimit(rateLimitKey, rateLimitConfig);
|
|
6290
|
-
if (!rateLimitResult.allowed) {
|
|
6291
|
-
logger3.warn(`Rate limit exceeded for ${operation}`, {
|
|
6292
|
-
identifier: rateLimitIdentifier,
|
|
6293
|
-
remaining: rateLimitResult.remaining,
|
|
6294
|
-
resetAt: rateLimitResult.resetAt,
|
|
6295
|
-
});
|
|
6296
|
-
throw new Error(
|
|
6297
|
-
`Rate limit exceeded. Try again in ${rateLimitResult.blockRemainingSeconds} seconds.`
|
|
6298
|
-
);
|
|
6299
|
-
}
|
|
6300
|
-
}
|
|
6301
|
-
const result = await businessLogic(validatedData, {
|
|
6302
|
-
uid,
|
|
6303
|
-
userRole,
|
|
6304
|
-
request,
|
|
6305
|
-
});
|
|
6306
|
-
if (process.env.ENABLE_METRICS === 'true') {
|
|
6307
|
-
const recordMetrics = await loadMonitoring();
|
|
6308
|
-
await recordMetrics({
|
|
6309
|
-
operation,
|
|
5615
|
+
const uid = assertAuthenticated(request.auth);
|
|
5616
|
+
const rateLimitKey = `${operation}_${uid}`;
|
|
5617
|
+
const rateLimitConfig =
|
|
5618
|
+
DEFAULT_RATE_LIMITS[operation] || DEFAULT_RATE_LIMITS.checkout;
|
|
5619
|
+
const rateLimitResult = await checkRateLimitWithFirestore(
|
|
5620
|
+
rateLimitKey,
|
|
5621
|
+
rateLimitConfig
|
|
5622
|
+
);
|
|
5623
|
+
if (!rateLimitResult.allowed) {
|
|
5624
|
+
logger3.warn(`Rate limit exceeded for ${operation}`, {
|
|
6310
5625
|
userId: uid,
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
metadata: {
|
|
6314
|
-
requestId: request.rawRequest.headers['x-request-id'] || 'unknown',
|
|
6315
|
-
},
|
|
5626
|
+
remaining: rateLimitResult.remaining,
|
|
5627
|
+
resetAt: rateLimitResult.resetAt,
|
|
6316
5628
|
});
|
|
5629
|
+
throw new Error(
|
|
5630
|
+
`Rate limit exceeded. Try again in ${rateLimitResult.blockRemainingSeconds} seconds.`
|
|
5631
|
+
);
|
|
6317
5632
|
}
|
|
5633
|
+
const result = await businessLogic(validatedData, { uid, request });
|
|
5634
|
+
await recordPaymentMetrics({
|
|
5635
|
+
operation,
|
|
5636
|
+
userId: uid,
|
|
5637
|
+
status: 'success',
|
|
5638
|
+
timestamp: /* @__PURE__ */ new Date().toISOString(),
|
|
5639
|
+
metadata: {
|
|
5640
|
+
requestId: request.rawRequest.headers['x-request-id'] || 'unknown',
|
|
5641
|
+
},
|
|
5642
|
+
});
|
|
6318
5643
|
return result;
|
|
6319
5644
|
} catch (error) {
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
},
|
|
6331
|
-
});
|
|
6332
|
-
}
|
|
5645
|
+
await recordPaymentMetrics({
|
|
5646
|
+
operation,
|
|
5647
|
+
userId: request.auth?.uid || 'anonymous',
|
|
5648
|
+
status: 'failed',
|
|
5649
|
+
timestamp: /* @__PURE__ */ new Date().toISOString(),
|
|
5650
|
+
metadata: {
|
|
5651
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
5652
|
+
requestId: request.rawRequest.headers['x-request-id'] || 'unknown',
|
|
5653
|
+
},
|
|
5654
|
+
});
|
|
6333
5655
|
throw handleError2(error);
|
|
6334
5656
|
}
|
|
6335
5657
|
});
|
|
6336
5658
|
}
|
|
6337
5659
|
__name(createBaseFunction, 'createBaseFunction');
|
|
6338
5660
|
|
|
5661
|
+
// src/firebase/config/secrets.ts
|
|
5662
|
+
import { defineSecret } from 'firebase-functions/params';
|
|
5663
|
+
var stripeSecretKey = defineSecret('STRIPE_SECRET_KEY');
|
|
5664
|
+
var stripeWebhookSecret = defineSecret('STRIPE_WEBHOOK_SECRET');
|
|
5665
|
+
var githubPersonalAccessToken = defineSecret('GITHUB_PERSONAL_ACCESS_TOKEN');
|
|
5666
|
+
|
|
6339
5667
|
// src/firebase/config/constants.ts
|
|
6340
5668
|
var FIREBASE_REGION = process.env.FIREBASE_REGION || 'europe-west1';
|
|
6341
5669
|
var ENFORCE_APP_CHECK = process.env.ENFORCE_APP_CHECK === 'true';
|
|
6342
5670
|
var BASE_CONFIG = {
|
|
6343
5671
|
region: FIREBASE_REGION,
|
|
5672
|
+
invoker: 'public',
|
|
5673
|
+
// Cloud Run allows HTTP, onCall validates Firebase Auth
|
|
6344
5674
|
...(ENFORCE_APP_CHECK && { enforceAppCheck: true }),
|
|
6345
5675
|
};
|
|
6346
5676
|
var FUNCTION_CONFIG = {
|
|
6347
5677
|
...BASE_CONFIG,
|
|
6348
|
-
invoker: 'public',
|
|
6349
|
-
// Cloud Run allows HTTP, onCall validates Firebase Auth
|
|
6350
5678
|
memory: '1GiB',
|
|
6351
5679
|
timeoutSeconds: 60,
|
|
6352
5680
|
cors: true,
|
|
@@ -6357,6 +5685,7 @@ var STRIPE_CONFIG = {
|
|
|
6357
5685
|
memory: '512MiB',
|
|
6358
5686
|
timeoutSeconds: 30,
|
|
6359
5687
|
cors: true,
|
|
5688
|
+
secrets: [stripeSecretKey, stripeWebhookSecret],
|
|
6360
5689
|
};
|
|
6361
5690
|
var AUTH_CONFIG = {
|
|
6362
5691
|
...BASE_CONFIG,
|
|
@@ -6365,17 +5694,6 @@ var AUTH_CONFIG = {
|
|
|
6365
5694
|
};
|
|
6366
5695
|
var CRUD_CONFIG = {
|
|
6367
5696
|
...BASE_CONFIG,
|
|
6368
|
-
invoker: 'public',
|
|
6369
|
-
// Cloud Run allows HTTP, onCall validates Firebase Auth + role-based access
|
|
6370
|
-
memory: '256MiB',
|
|
6371
|
-
timeoutSeconds: 15,
|
|
6372
|
-
cors: true,
|
|
6373
|
-
// Enable CORS for cross-origin requests (required for web apps)
|
|
6374
|
-
};
|
|
6375
|
-
var CRUD_READ_CONFIG = {
|
|
6376
|
-
...BASE_CONFIG,
|
|
6377
|
-
invoker: 'public',
|
|
6378
|
-
// Cloud Run allows HTTP, onCall validates Firebase Auth
|
|
6379
5697
|
memory: '256MiB',
|
|
6380
5698
|
timeoutSeconds: 15,
|
|
6381
5699
|
cors: true,
|
|
@@ -6429,8 +5747,8 @@ var getCustomClaims = /* @__PURE__ */ __name((customSchema) => {
|
|
|
6429
5747
|
}, 'getCustomClaims');
|
|
6430
5748
|
|
|
6431
5749
|
// src/firebase/auth/getUserAuthStatus.ts
|
|
5750
|
+
init_server4();
|
|
6432
5751
|
init_dist();
|
|
6433
|
-
init_server3();
|
|
6434
5752
|
var getUserAuthStatusSchema = object({});
|
|
6435
5753
|
async function getUserAuthStatusLogic(data, context) {
|
|
6436
5754
|
const user = await getFirebaseAdminAuth().getUser(context.uid);
|
|
@@ -6454,8 +5772,8 @@ var getUserAuthStatus = /* @__PURE__ */ __name((customSchema) => {
|
|
|
6454
5772
|
}, 'getUserAuthStatus');
|
|
6455
5773
|
|
|
6456
5774
|
// src/firebase/auth/removeCustomClaims.ts
|
|
5775
|
+
init_server4();
|
|
6457
5776
|
init_dist();
|
|
6458
|
-
init_server3();
|
|
6459
5777
|
var removeCustomClaimsSchema = object({
|
|
6460
5778
|
claimsToRemove: pipe(
|
|
6461
5779
|
array(string()),
|
|
@@ -6485,8 +5803,8 @@ var removeCustomClaims = /* @__PURE__ */ __name((customSchema) => {
|
|
|
6485
5803
|
}, 'removeCustomClaims');
|
|
6486
5804
|
|
|
6487
5805
|
// src/firebase/auth/setCustomClaims.ts
|
|
5806
|
+
init_server4();
|
|
6488
5807
|
init_dist();
|
|
6489
|
-
init_server3();
|
|
6490
5808
|
var setCustomClaimsSchema = object({
|
|
6491
5809
|
customClaims: record(string(), any()),
|
|
6492
5810
|
idempotencyKey: optional(string()),
|
|
@@ -6536,8 +5854,8 @@ var setCustomClaims = /* @__PURE__ */ __name((customSchema) => {
|
|
|
6536
5854
|
}, 'setCustomClaims');
|
|
6537
5855
|
|
|
6538
5856
|
// src/firebase/billing/createCheckoutSession.ts
|
|
6539
|
-
|
|
6540
|
-
|
|
5857
|
+
init_server4();
|
|
5858
|
+
init_server3();
|
|
6541
5859
|
init_server3();
|
|
6542
5860
|
import { logger as logger5 } from 'firebase-functions/v2';
|
|
6543
5861
|
|
|
@@ -6612,12 +5930,6 @@ function validateMetadata(metadata) {
|
|
|
6612
5930
|
}
|
|
6613
5931
|
__name(validateMetadata, 'validateMetadata');
|
|
6614
5932
|
|
|
6615
|
-
// src/firebase/config/secrets.ts
|
|
6616
|
-
import { defineSecret } from 'firebase-functions/params';
|
|
6617
|
-
var stripeSecretKey = defineSecret('STRIPE_SECRET_KEY');
|
|
6618
|
-
var stripeWebhookSecret = defineSecret('STRIPE_WEBHOOK_SECRET');
|
|
6619
|
-
var githubPersonalAccessToken = defineSecret('GITHUB_PERSONAL_ACCESS_TOKEN');
|
|
6620
|
-
|
|
6621
5933
|
// src/firebase/billing/createCheckoutSession.ts
|
|
6622
5934
|
async function createCheckoutSessionLogic(data, context, billingConfig) {
|
|
6623
5935
|
initStripe(stripeSecretKey.value());
|
|
@@ -6811,7 +6123,7 @@ async function updateUserSubscription(userId, subscriptionData, authProvider) {
|
|
|
6811
6123
|
__name(updateUserSubscription, 'updateUserSubscription');
|
|
6812
6124
|
|
|
6813
6125
|
// src/shared/billing/webhookHandler.ts
|
|
6814
|
-
|
|
6126
|
+
init_server3();
|
|
6815
6127
|
import 'stripe';
|
|
6816
6128
|
|
|
6817
6129
|
// src/shared/logger.ts
|
|
@@ -7020,7 +6332,7 @@ async function isFirestoreAvailable() {
|
|
|
7020
6332
|
}
|
|
7021
6333
|
try {
|
|
7022
6334
|
const { getFirebaseAdminFirestore: getFirebaseAdminFirestore2 } =
|
|
7023
|
-
await Promise.resolve().then(() => (
|
|
6335
|
+
await Promise.resolve().then(() => (init_server4(), server_exports2));
|
|
7024
6336
|
const db = getFirebaseAdminFirestore2();
|
|
7025
6337
|
await db.collection('_health_check').limit(1).get();
|
|
7026
6338
|
return true;
|
|
@@ -7068,7 +6380,7 @@ var FirestoreIdempotency = class {
|
|
|
7068
6380
|
async init() {
|
|
7069
6381
|
if (this.initialized) return;
|
|
7070
6382
|
const { getFirebaseAdminFirestore: getFirebaseAdminFirestore2 } =
|
|
7071
|
-
await Promise.resolve().then(() => (
|
|
6383
|
+
await Promise.resolve().then(() => (init_server4(), server_exports2));
|
|
7072
6384
|
this.db = getFirebaseAdminFirestore2();
|
|
7073
6385
|
this.initialized = true;
|
|
7074
6386
|
}
|
|
@@ -7131,7 +6443,7 @@ function resetIdempotencyStore() {
|
|
|
7131
6443
|
__name(resetIdempotencyStore, 'resetIdempotencyStore');
|
|
7132
6444
|
|
|
7133
6445
|
// src/shared/utils/external/date.ts
|
|
7134
|
-
|
|
6446
|
+
init_server4();
|
|
7135
6447
|
function addMonths(date, months) {
|
|
7136
6448
|
const result = new Date(date);
|
|
7137
6449
|
const originalDate = result.getDate();
|
|
@@ -7612,8 +6924,8 @@ var billingHealth = onRequest2(STRIPE_CONFIG, async (req, res) => {
|
|
|
7612
6924
|
});
|
|
7613
6925
|
|
|
7614
6926
|
// src/firebase/billing/refreshSubscriptionStatus.ts
|
|
6927
|
+
init_server4();
|
|
7615
6928
|
init_dist();
|
|
7616
|
-
init_server3();
|
|
7617
6929
|
import 'stripe';
|
|
7618
6930
|
var refreshSubscriptionStatusSchema = object({
|
|
7619
6931
|
userId: pipe(string(), minLength(1, 'User ID is required')),
|
|
@@ -7665,11 +6977,11 @@ var refreshSubscriptionStatus = /* @__PURE__ */ __name((customSchema) => {
|
|
|
7665
6977
|
}, 'refreshSubscriptionStatus');
|
|
7666
6978
|
|
|
7667
6979
|
// src/firebase/billing/cancelSubscription.ts
|
|
6980
|
+
init_server4();
|
|
7668
6981
|
init_dist();
|
|
7669
|
-
init_server3();
|
|
7670
6982
|
|
|
7671
6983
|
// src/shared/billing/helpers/subscriptionManagement.ts
|
|
7672
|
-
|
|
6984
|
+
init_server3();
|
|
7673
6985
|
import 'stripe';
|
|
7674
6986
|
async function cancelUserSubscription(userId, authProvider) {
|
|
7675
6987
|
validateStripeEnvironment();
|
|
@@ -7747,8 +7059,8 @@ function cancelSubscription() {
|
|
|
7747
7059
|
__name(cancelSubscription, 'cancelSubscription');
|
|
7748
7060
|
|
|
7749
7061
|
// src/firebase/billing/changePlan.ts
|
|
7062
|
+
init_server4();
|
|
7750
7063
|
init_dist();
|
|
7751
|
-
init_server3();
|
|
7752
7064
|
import 'stripe';
|
|
7753
7065
|
var changePlanSchema = object({
|
|
7754
7066
|
userId: string(),
|
|
@@ -7834,8 +7146,8 @@ function changePlan(billingConfig) {
|
|
|
7834
7146
|
__name(changePlan, 'changePlan');
|
|
7835
7147
|
|
|
7836
7148
|
// src/firebase/billing/createCustomerPortal.ts
|
|
7149
|
+
init_server4();
|
|
7837
7150
|
init_dist();
|
|
7838
|
-
init_server3();
|
|
7839
7151
|
var customerPortalSchema = object({
|
|
7840
7152
|
userId: string(),
|
|
7841
7153
|
returnUrl: optional(pipe(string(), url())),
|
|
@@ -7878,7 +7190,7 @@ __name(createCustomerPortal, 'createCustomerPortal');
|
|
|
7878
7190
|
|
|
7879
7191
|
// src/firebase/crud/aggregate.ts
|
|
7880
7192
|
init_dist();
|
|
7881
|
-
|
|
7193
|
+
init_server4();
|
|
7882
7194
|
|
|
7883
7195
|
// src/shared/schema.ts
|
|
7884
7196
|
function isFieldVisible2(key, visibility, isAdmin, isAuthenticated = true) {
|
|
@@ -7894,9 +7206,6 @@ function isFieldVisible2(key, visibility, isAdmin, isAuthenticated = true) {
|
|
|
7894
7206
|
if (visibility === 'technical') {
|
|
7895
7207
|
return isAdmin;
|
|
7896
7208
|
}
|
|
7897
|
-
if (visibility === 'owner') {
|
|
7898
|
-
return false;
|
|
7899
|
-
}
|
|
7900
7209
|
if (visibility === 'user' || visibility === void 0) {
|
|
7901
7210
|
return isAuthenticated;
|
|
7902
7211
|
}
|
|
@@ -7917,49 +7226,24 @@ function canAggregateField(fieldName, schema, isAdmin) {
|
|
|
7917
7226
|
return isFieldVisible2(fieldName, visibility, isAdmin);
|
|
7918
7227
|
}
|
|
7919
7228
|
__name(canAggregateField, 'canAggregateField');
|
|
7920
|
-
function getPriceOrNumberValue(raw) {
|
|
7921
|
-
if (raw != null && typeof raw === 'object' && 'amount' in raw) {
|
|
7922
|
-
const obj = raw;
|
|
7923
|
-
const amount = Number(obj.amount);
|
|
7924
|
-
if (!Number.isFinite(amount)) return NaN;
|
|
7925
|
-
const discountPercent = Number(obj.discountPercent);
|
|
7926
|
-
const pct = Number.isFinite(discountPercent)
|
|
7927
|
-
? Math.min(100, Math.max(0, discountPercent))
|
|
7928
|
-
: 0;
|
|
7929
|
-
return pct > 0 ? amount * (1 - pct / 100) : amount;
|
|
7930
|
-
}
|
|
7931
|
-
const n = Number(raw);
|
|
7932
|
-
return Number.isFinite(n) ? n : NaN;
|
|
7933
|
-
}
|
|
7934
|
-
__name(getPriceOrNumberValue, 'getPriceOrNumberValue');
|
|
7935
|
-
function getNumericValue(doc, field) {
|
|
7936
|
-
return getPriceOrNumberValue(doc[field]);
|
|
7937
|
-
}
|
|
7938
|
-
__name(getNumericValue, 'getNumericValue');
|
|
7939
7229
|
function computeMetric(docs, metric) {
|
|
7940
7230
|
let filtered = docs;
|
|
7941
7231
|
if (metric.filter) {
|
|
7942
7232
|
filtered = docs.filter((doc) => {
|
|
7943
7233
|
const value = doc[metric.filter.field];
|
|
7944
|
-
const comparable =
|
|
7945
|
-
value != null && typeof value === 'object' && 'amount' in value
|
|
7946
|
-
? getPriceOrNumberValue(value)
|
|
7947
|
-
: typeof value === 'number' || value == null
|
|
7948
|
-
? value
|
|
7949
|
-
: Number(value);
|
|
7950
7234
|
switch (metric.filter.operator) {
|
|
7951
7235
|
case '==':
|
|
7952
7236
|
return value === metric.filter.value;
|
|
7953
7237
|
case '!=':
|
|
7954
7238
|
return value !== metric.filter.value;
|
|
7955
7239
|
case '>':
|
|
7956
|
-
return
|
|
7240
|
+
return value > metric.filter.value;
|
|
7957
7241
|
case '<':
|
|
7958
|
-
return
|
|
7242
|
+
return value < metric.filter.value;
|
|
7959
7243
|
case '>=':
|
|
7960
|
-
return
|
|
7244
|
+
return value >= metric.filter.value;
|
|
7961
7245
|
case '<=':
|
|
7962
|
-
return
|
|
7246
|
+
return value <= metric.filter.value;
|
|
7963
7247
|
default:
|
|
7964
7248
|
return true;
|
|
7965
7249
|
}
|
|
@@ -7970,31 +7254,31 @@ function computeMetric(docs, metric) {
|
|
|
7970
7254
|
return filtered.length;
|
|
7971
7255
|
case 'sum': {
|
|
7972
7256
|
return filtered.reduce((sum, doc) => {
|
|
7973
|
-
const val =
|
|
7974
|
-
return sum +
|
|
7257
|
+
const val = Number(doc[metric.field]) || 0;
|
|
7258
|
+
return sum + val;
|
|
7975
7259
|
}, 0);
|
|
7976
7260
|
}
|
|
7977
7261
|
case 'avg': {
|
|
7978
7262
|
if (filtered.length === 0) return null;
|
|
7979
7263
|
const sum = filtered.reduce((s, doc) => {
|
|
7980
|
-
const val =
|
|
7981
|
-
return s +
|
|
7264
|
+
const val = Number(doc[metric.field]) || 0;
|
|
7265
|
+
return s + val;
|
|
7982
7266
|
}, 0);
|
|
7983
7267
|
return sum / filtered.length;
|
|
7984
7268
|
}
|
|
7985
7269
|
case 'min': {
|
|
7986
7270
|
if (filtered.length === 0) return null;
|
|
7987
7271
|
return filtered.reduce((min, doc) => {
|
|
7988
|
-
const val =
|
|
7989
|
-
if (
|
|
7272
|
+
const val = Number(doc[metric.field]);
|
|
7273
|
+
if (isNaN(val)) return min;
|
|
7990
7274
|
return min === null ? val : Math.min(min, val);
|
|
7991
7275
|
}, null);
|
|
7992
7276
|
}
|
|
7993
7277
|
case 'max': {
|
|
7994
7278
|
if (filtered.length === 0) return null;
|
|
7995
7279
|
return filtered.reduce((max, doc) => {
|
|
7996
|
-
const val =
|
|
7997
|
-
if (
|
|
7280
|
+
const val = Number(doc[metric.field]);
|
|
7281
|
+
if (isNaN(val)) return max;
|
|
7998
7282
|
return max === null ? val : Math.max(max, val);
|
|
7999
7283
|
}, null);
|
|
8000
7284
|
}
|
|
@@ -8110,7 +7394,7 @@ var aggregateEntities = /* @__PURE__ */ __name(
|
|
|
8110
7394
|
|
|
8111
7395
|
// src/firebase/crud/create.ts
|
|
8112
7396
|
init_dist();
|
|
8113
|
-
|
|
7397
|
+
init_server4();
|
|
8114
7398
|
init_server3();
|
|
8115
7399
|
|
|
8116
7400
|
// src/shared/github.ts
|
|
@@ -8333,6 +7617,49 @@ function updateMetadata(userId) {
|
|
|
8333
7617
|
__name(updateMetadata, 'updateMetadata');
|
|
8334
7618
|
|
|
8335
7619
|
// src/shared/firebase.ts
|
|
7620
|
+
function createTimestamp2(date) {
|
|
7621
|
+
return {
|
|
7622
|
+
seconds: Math.floor(date.getTime() / 1e3),
|
|
7623
|
+
nanoseconds: (date.getTime() % 1e3) * 1e6,
|
|
7624
|
+
toDate: /* @__PURE__ */ __name(() => new Date(date), 'toDate'),
|
|
7625
|
+
toMillis: /* @__PURE__ */ __name(() => date.getTime(), 'toMillis'),
|
|
7626
|
+
isEqual: /* @__PURE__ */ __name(
|
|
7627
|
+
(other) =>
|
|
7628
|
+
other.seconds === Math.floor(date.getTime() / 1e3) &&
|
|
7629
|
+
other.nanoseconds === (date.getTime() % 1e3) * 1e6,
|
|
7630
|
+
'isEqual'
|
|
7631
|
+
),
|
|
7632
|
+
valueOf: /* @__PURE__ */ __name(
|
|
7633
|
+
() =>
|
|
7634
|
+
`Timestamp(seconds=${Math.floor(date.getTime() / 1e3)}, nanoseconds=${(date.getTime() % 1e3) * 1e6})`,
|
|
7635
|
+
'valueOf'
|
|
7636
|
+
),
|
|
7637
|
+
};
|
|
7638
|
+
}
|
|
7639
|
+
__name(createTimestamp2, 'createTimestamp');
|
|
7640
|
+
function toTimestamp2(date) {
|
|
7641
|
+
try {
|
|
7642
|
+
if (typeof date === 'string') {
|
|
7643
|
+
const parsed = new Date(date);
|
|
7644
|
+
if (isNaN(parsed.getTime())) {
|
|
7645
|
+
throw new Error(`Invalid date string format: ${date}`);
|
|
7646
|
+
}
|
|
7647
|
+
return createTimestamp2(parsed);
|
|
7648
|
+
}
|
|
7649
|
+
if (date instanceof Date) {
|
|
7650
|
+
if (isNaN(date.getTime())) {
|
|
7651
|
+
throw new Error('Invalid Date object');
|
|
7652
|
+
}
|
|
7653
|
+
return createTimestamp2(date);
|
|
7654
|
+
}
|
|
7655
|
+
throw new Error('Date must be a string or Date object');
|
|
7656
|
+
} catch (error) {
|
|
7657
|
+
throw new Error(
|
|
7658
|
+
`Failed to convert to timestamp: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
7659
|
+
);
|
|
7660
|
+
}
|
|
7661
|
+
}
|
|
7662
|
+
__name(toTimestamp2, 'toTimestamp');
|
|
8336
7663
|
function toISOString(timestamp) {
|
|
8337
7664
|
return timestamp.toDate().toISOString();
|
|
8338
7665
|
}
|
|
@@ -8394,7 +7721,9 @@ function prepareForFirestore2(data, removeFields = []) {
|
|
|
8394
7721
|
continue;
|
|
8395
7722
|
}
|
|
8396
7723
|
if (value instanceof Date) {
|
|
8397
|
-
prepared[key] = value
|
|
7724
|
+
prepared[key] = toTimestamp2(value);
|
|
7725
|
+
} else if (typeof value === 'string' && isISODateString2(value)) {
|
|
7726
|
+
prepared[key] = toTimestamp2(value);
|
|
8398
7727
|
} else {
|
|
8399
7728
|
prepared[key] = prepareForFirestore2(value, removeFields);
|
|
8400
7729
|
}
|
|
@@ -8402,78 +7731,34 @@ function prepareForFirestore2(data, removeFields = []) {
|
|
|
8402
7731
|
return prepared;
|
|
8403
7732
|
}
|
|
8404
7733
|
if (data instanceof Date) {
|
|
8405
|
-
return data
|
|
7734
|
+
return toTimestamp2(data);
|
|
7735
|
+
}
|
|
7736
|
+
if (typeof data === 'string' && isISODateString2(data)) {
|
|
7737
|
+
return toTimestamp2(data);
|
|
8406
7738
|
}
|
|
8407
7739
|
return data;
|
|
8408
7740
|
}
|
|
8409
7741
|
__name(prepareForFirestore2, 'prepareForFirestore');
|
|
7742
|
+
function isISODateString2(str) {
|
|
7743
|
+
if (typeof str !== 'string') return false;
|
|
7744
|
+
const isoDatePattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?$/;
|
|
7745
|
+
if (!isoDatePattern.test(str)) return false;
|
|
7746
|
+
const date = new Date(str);
|
|
7747
|
+
return (
|
|
7748
|
+
!isNaN(date.getTime()) &&
|
|
7749
|
+
date.toISOString().startsWith(str.substring(0, 19))
|
|
7750
|
+
);
|
|
7751
|
+
}
|
|
7752
|
+
__name(isISODateString2, 'isISODateString');
|
|
8410
7753
|
|
|
8411
7754
|
// src/firebase/crud/create.ts
|
|
8412
|
-
function normalizeValue(value) {
|
|
8413
|
-
if (typeof value === 'string') {
|
|
8414
|
-
return value.toLowerCase();
|
|
8415
|
-
}
|
|
8416
|
-
return value;
|
|
8417
|
-
}
|
|
8418
|
-
__name(normalizeValue, 'normalizeValue');
|
|
8419
|
-
function normalizePayloadForUniqueKeys(payload, uniqueKeys) {
|
|
8420
|
-
const normalized = { ...payload };
|
|
8421
|
-
for (const uniqueKey of uniqueKeys) {
|
|
8422
|
-
for (const field of uniqueKey.fields) {
|
|
8423
|
-
if (typeof normalized[field] === 'string') {
|
|
8424
|
-
normalized[field] = normalized[field].toLowerCase();
|
|
8425
|
-
}
|
|
8426
|
-
}
|
|
8427
|
-
}
|
|
8428
|
-
return normalized;
|
|
8429
|
-
}
|
|
8430
|
-
__name(normalizePayloadForUniqueKeys, 'normalizePayloadForUniqueKeys');
|
|
8431
|
-
async function checkUniqueKeys(collection, payload, uniqueKeys, isDraft) {
|
|
8432
|
-
const db = getFirebaseAdminFirestore();
|
|
8433
|
-
for (const uniqueKey of uniqueKeys) {
|
|
8434
|
-
const skipForDrafts = uniqueKey.skipForDrafts !== false;
|
|
8435
|
-
if (isDraft && skipForDrafts) continue;
|
|
8436
|
-
const allFieldsHaveValues = uniqueKey.fields.every(
|
|
8437
|
-
(field) => payload[field] != null && payload[field] !== ''
|
|
8438
|
-
);
|
|
8439
|
-
if (!allFieldsHaveValues) continue;
|
|
8440
|
-
let query = db.collection(collection);
|
|
8441
|
-
for (const field of uniqueKey.fields) {
|
|
8442
|
-
query = query.where(field, '==', normalizeValue(payload[field]));
|
|
8443
|
-
}
|
|
8444
|
-
const existing = await query.limit(1).get();
|
|
8445
|
-
if (!existing.empty) {
|
|
8446
|
-
const firstDoc = existing.docs[0];
|
|
8447
|
-
const existingDoc = transformFirestoreData2({
|
|
8448
|
-
id: firstDoc.id,
|
|
8449
|
-
...firstDoc.data(),
|
|
8450
|
-
});
|
|
8451
|
-
if (uniqueKey.findOrCreate) {
|
|
8452
|
-
return { found: true, existingDoc, findOrCreate: true };
|
|
8453
|
-
}
|
|
8454
|
-
const fieldNames = uniqueKey.fields.join(' + ');
|
|
8455
|
-
throw new DoNotDevError(
|
|
8456
|
-
uniqueKey.errorMessage || `Duplicate ${fieldNames}`,
|
|
8457
|
-
'already-exists',
|
|
8458
|
-
{
|
|
8459
|
-
details: {
|
|
8460
|
-
fields: uniqueKey.fields,
|
|
8461
|
-
existingId: firstDoc.id,
|
|
8462
|
-
},
|
|
8463
|
-
}
|
|
8464
|
-
);
|
|
8465
|
-
}
|
|
8466
|
-
}
|
|
8467
|
-
return { found: false };
|
|
8468
|
-
}
|
|
8469
|
-
__name(checkUniqueKeys, 'checkUniqueKeys');
|
|
8470
7755
|
function createEntityLogicFactory(collection, documentSchema) {
|
|
8471
7756
|
return /* @__PURE__ */ __name(async function createEntityLogic(
|
|
8472
7757
|
data,
|
|
8473
7758
|
context
|
|
8474
7759
|
) {
|
|
8475
7760
|
const { payload, idempotencyKey } = data;
|
|
8476
|
-
const
|
|
7761
|
+
const uid = await assertAdmin(context.uid);
|
|
8477
7762
|
if (idempotencyKey) {
|
|
8478
7763
|
const db2 = getFirebaseAdminFirestore();
|
|
8479
7764
|
const idempotencyRef = db2
|
|
@@ -8486,28 +7771,11 @@ function createEntityLogicFactory(collection, documentSchema) {
|
|
|
8486
7771
|
}
|
|
8487
7772
|
const status = payload.status ?? DEFAULT_STATUS_VALUE;
|
|
8488
7773
|
const isDraft = status === 'draft';
|
|
8489
|
-
const schemaWithMeta = documentSchema;
|
|
8490
|
-
const uniqueKeys = schemaWithMeta.metadata?.uniqueKeys;
|
|
8491
|
-
if (uniqueKeys && uniqueKeys.length > 0) {
|
|
8492
|
-
const checkResult = await checkUniqueKeys(
|
|
8493
|
-
collection,
|
|
8494
|
-
payload,
|
|
8495
|
-
uniqueKeys,
|
|
8496
|
-
isDraft
|
|
8497
|
-
);
|
|
8498
|
-
if (checkResult.found && checkResult.findOrCreate) {
|
|
8499
|
-
return checkResult.existingDoc;
|
|
8500
|
-
}
|
|
8501
|
-
}
|
|
8502
|
-
const normalizedPayload =
|
|
8503
|
-
uniqueKeys && uniqueKeys.length > 0
|
|
8504
|
-
? normalizePayloadForUniqueKeys(payload, uniqueKeys)
|
|
8505
|
-
: payload;
|
|
8506
7774
|
if (!isDraft) {
|
|
8507
|
-
validateDocument(
|
|
7775
|
+
validateDocument(payload, documentSchema);
|
|
8508
7776
|
}
|
|
8509
7777
|
const documentData = {
|
|
8510
|
-
...prepareForFirestore2(
|
|
7778
|
+
...prepareForFirestore2(payload),
|
|
8511
7779
|
status,
|
|
8512
7780
|
// Ensure status is always present
|
|
8513
7781
|
...createMetadata(uid),
|
|
@@ -8534,7 +7802,7 @@ function createEntityLogicFactory(collection, documentSchema) {
|
|
|
8534
7802
|
}
|
|
8535
7803
|
__name(createEntityLogicFactory, 'createEntityLogicFactory');
|
|
8536
7804
|
var createEntity = /* @__PURE__ */ __name(
|
|
8537
|
-
(collection, documentSchema,
|
|
7805
|
+
(collection, documentSchema, customSchema) => {
|
|
8538
7806
|
const requestSchema =
|
|
8539
7807
|
customSchema ||
|
|
8540
7808
|
object({
|
|
@@ -8545,22 +7813,22 @@ var createEntity = /* @__PURE__ */ __name(
|
|
|
8545
7813
|
CRUD_CONFIG,
|
|
8546
7814
|
requestSchema,
|
|
8547
7815
|
'create_entity',
|
|
8548
|
-
createEntityLogicFactory(collection, documentSchema)
|
|
8549
|
-
requiredRole
|
|
7816
|
+
createEntityLogicFactory(collection, documentSchema)
|
|
8550
7817
|
);
|
|
8551
7818
|
},
|
|
8552
7819
|
'createEntity'
|
|
8553
7820
|
);
|
|
8554
7821
|
|
|
8555
7822
|
// src/firebase/crud/delete.ts
|
|
7823
|
+
init_server4();
|
|
8556
7824
|
init_dist();
|
|
8557
|
-
init_server3();
|
|
8558
7825
|
function deleteEntityLogicFactory(collection) {
|
|
8559
7826
|
return /* @__PURE__ */ __name(async function deleteEntityLogic(
|
|
8560
7827
|
data,
|
|
8561
7828
|
context
|
|
8562
7829
|
) {
|
|
8563
7830
|
const { id } = data;
|
|
7831
|
+
await assertAdmin(context.uid);
|
|
8564
7832
|
const references = await findReferences(collection, id);
|
|
8565
7833
|
if (references.length > 0) {
|
|
8566
7834
|
throw new DoNotDevError(
|
|
@@ -8575,51 +7843,44 @@ function deleteEntityLogicFactory(collection) {
|
|
|
8575
7843
|
}, 'deleteEntityLogic');
|
|
8576
7844
|
}
|
|
8577
7845
|
__name(deleteEntityLogicFactory, 'deleteEntityLogicFactory');
|
|
8578
|
-
var deleteEntity = /* @__PURE__ */ __name(
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
);
|
|
8592
|
-
},
|
|
8593
|
-
'deleteEntity'
|
|
8594
|
-
);
|
|
7846
|
+
var deleteEntity = /* @__PURE__ */ __name((collection, customSchema) => {
|
|
7847
|
+
const requestSchema =
|
|
7848
|
+
customSchema ||
|
|
7849
|
+
object({
|
|
7850
|
+
id: pipe(string(), minLength(1)),
|
|
7851
|
+
});
|
|
7852
|
+
return createBaseFunction(
|
|
7853
|
+
CRUD_CONFIG,
|
|
7854
|
+
requestSchema,
|
|
7855
|
+
'delete_entity',
|
|
7856
|
+
deleteEntityLogicFactory(collection)
|
|
7857
|
+
);
|
|
7858
|
+
}, 'deleteEntity');
|
|
8595
7859
|
|
|
8596
7860
|
// src/firebase/crud/get.ts
|
|
8597
7861
|
init_dist();
|
|
8598
|
-
init_server2();
|
|
8599
7862
|
init_server3();
|
|
8600
|
-
|
|
7863
|
+
init_server3();
|
|
7864
|
+
init_server4();
|
|
7865
|
+
function getEntityLogicFactory(collection, documentSchema) {
|
|
8601
7866
|
return /* @__PURE__ */ __name(async function getEntityLogic(data, context) {
|
|
8602
7867
|
const { id } = data;
|
|
8603
|
-
const { userRole, uid } = context;
|
|
8604
7868
|
const db = getFirebaseAdminFirestore();
|
|
8605
7869
|
const docRef = db.collection(collection).doc(id);
|
|
8606
7870
|
const doc = await docRef.get();
|
|
8607
7871
|
if (!doc.exists) {
|
|
8608
7872
|
throw new DoNotDevError('Entity not found', 'not-found');
|
|
8609
7873
|
}
|
|
8610
|
-
const
|
|
7874
|
+
const userRole = getUserRole(context.request.auth);
|
|
7875
|
+
const isAdmin = userRole === 'admin' || userRole === 'super';
|
|
8611
7876
|
const docData = doc.data();
|
|
8612
7877
|
if (!isAdmin && HIDDEN_STATUSES.includes(docData?.status)) {
|
|
8613
7878
|
throw new DoNotDevError('Entity not found', 'not-found');
|
|
8614
7879
|
}
|
|
8615
|
-
const rawData = docData || {};
|
|
8616
|
-
const visibilityOptions =
|
|
8617
|
-
ownership && uid ? { documentData: rawData, uid, ownership } : void 0;
|
|
8618
7880
|
const filteredData = filterVisibleFields(
|
|
8619
|
-
|
|
7881
|
+
docData || {},
|
|
8620
7882
|
documentSchema,
|
|
8621
|
-
userRole
|
|
8622
|
-
visibilityOptions
|
|
7883
|
+
userRole
|
|
8623
7884
|
);
|
|
8624
7885
|
return transformFirestoreData2({
|
|
8625
7886
|
id: doc.id,
|
|
@@ -8629,68 +7890,41 @@ function getEntityLogicFactory(collection, documentSchema, ownership) {
|
|
|
8629
7890
|
}
|
|
8630
7891
|
__name(getEntityLogicFactory, 'getEntityLogicFactory');
|
|
8631
7892
|
var getEntity = /* @__PURE__ */ __name(
|
|
8632
|
-
(collection, documentSchema,
|
|
7893
|
+
(collection, documentSchema, customSchema) => {
|
|
8633
7894
|
const requestSchema =
|
|
8634
7895
|
customSchema ||
|
|
8635
7896
|
object({
|
|
8636
7897
|
id: pipe(string(), minLength(1)),
|
|
8637
7898
|
});
|
|
8638
7899
|
return createBaseFunction(
|
|
8639
|
-
|
|
7900
|
+
CRUD_CONFIG,
|
|
8640
7901
|
requestSchema,
|
|
8641
7902
|
'get_entity',
|
|
8642
|
-
getEntityLogicFactory(collection, documentSchema
|
|
8643
|
-
requiredRole
|
|
7903
|
+
getEntityLogicFactory(collection, documentSchema)
|
|
8644
7904
|
);
|
|
8645
7905
|
},
|
|
8646
7906
|
'getEntity'
|
|
8647
7907
|
);
|
|
8648
7908
|
|
|
8649
7909
|
// src/firebase/crud/list.ts
|
|
7910
|
+
init_server4();
|
|
7911
|
+
init_server3();
|
|
8650
7912
|
init_dist();
|
|
8651
|
-
|
|
7913
|
+
init_server4();
|
|
8652
7914
|
init_server3();
|
|
8653
|
-
function
|
|
8654
|
-
let q = query;
|
|
8655
|
-
for (const c of publicCondition) {
|
|
8656
|
-
q = q.where(c.field, c.op, c.value);
|
|
8657
|
-
}
|
|
8658
|
-
return q;
|
|
8659
|
-
}
|
|
8660
|
-
__name(applyPublicCondition, 'applyPublicCondition');
|
|
8661
|
-
function listEntitiesLogicFactory(
|
|
8662
|
-
collection,
|
|
8663
|
-
documentSchema,
|
|
8664
|
-
listFields,
|
|
8665
|
-
ownership,
|
|
8666
|
-
isListCard
|
|
8667
|
-
) {
|
|
7915
|
+
function listEntitiesLogicFactory(collection, documentSchema) {
|
|
8668
7916
|
return /* @__PURE__ */ __name(async function listEntitiesLogic(
|
|
8669
7917
|
data,
|
|
8670
7918
|
context
|
|
8671
7919
|
) {
|
|
8672
|
-
const { where = [], orderBy = [], limit, startAfterId, search } = data;
|
|
8673
|
-
const
|
|
8674
|
-
const isAdmin =
|
|
7920
|
+
const { where = [], orderBy = [], limit = 50, startAfterId, search } = data;
|
|
7921
|
+
const userRole = getUserRole(context.request.auth);
|
|
7922
|
+
const isAdmin = userRole === 'admin' || userRole === 'super';
|
|
8675
7923
|
const db = getFirebaseAdminFirestore();
|
|
8676
7924
|
let query = db.collection(collection);
|
|
8677
7925
|
if (!isAdmin) {
|
|
8678
7926
|
query = query.where('status', 'not-in', [...HIDDEN_STATUSES]);
|
|
8679
7927
|
}
|
|
8680
|
-
if (ownership && !isAdmin) {
|
|
8681
|
-
if (
|
|
8682
|
-
isListCard &&
|
|
8683
|
-
ownership.publicCondition &&
|
|
8684
|
-
ownership.publicCondition.length > 0
|
|
8685
|
-
) {
|
|
8686
|
-
query = applyPublicCondition(query, ownership.publicCondition);
|
|
8687
|
-
} else if (!isListCard && ownership.ownerFields.length > 0) {
|
|
8688
|
-
const firstOwnerField = ownership.ownerFields[0];
|
|
8689
|
-
query = query.where(firstOwnerField, '==', uid);
|
|
8690
|
-
if (ownership.ownerFields.length > 1) {
|
|
8691
|
-
}
|
|
8692
|
-
}
|
|
8693
|
-
}
|
|
8694
7928
|
if (search) {
|
|
8695
7929
|
const { field, query: searchQuery } = search;
|
|
8696
7930
|
query = query
|
|
@@ -8713,70 +7947,12 @@ function listEntitiesLogicFactory(
|
|
|
8713
7947
|
}
|
|
8714
7948
|
query = query.startAfter(startAfterDoc);
|
|
8715
7949
|
}
|
|
8716
|
-
|
|
8717
|
-
query = query.limit(limit);
|
|
8718
|
-
}
|
|
8719
|
-
console.log(
|
|
8720
|
-
`[listEntities] Collection: ${collection}, UserRole: ${userRole}, IsAdmin: ${isAdmin}`
|
|
8721
|
-
);
|
|
8722
|
-
console.log(
|
|
8723
|
-
`[listEntities] Filters - where: ${JSON.stringify(where)}, orderBy: ${JSON.stringify(orderBy)}, limit: ${limit}`
|
|
8724
|
-
);
|
|
7950
|
+
query = query.limit(limit);
|
|
8725
7951
|
const snapshot = await query.get();
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
console.log(`[listEntities] Schema has entries: ${schemaHasEntries}`);
|
|
8731
|
-
const isPictureObject = /* @__PURE__ */ __name((value) => {
|
|
8732
|
-
return (
|
|
8733
|
-
typeof value === 'object' &&
|
|
8734
|
-
value !== null &&
|
|
8735
|
-
'thumbUrl' in value &&
|
|
8736
|
-
'fullUrl' in value
|
|
8737
|
-
);
|
|
8738
|
-
}, 'isPictureObject');
|
|
8739
|
-
const optimizePictureField = /* @__PURE__ */ __name((value) => {
|
|
8740
|
-
if (Array.isArray(value) && value.length > 0) {
|
|
8741
|
-
const firstPicture = value[0];
|
|
8742
|
-
if (isPictureObject(firstPicture)) {
|
|
8743
|
-
return firstPicture.thumbUrl || firstPicture.fullUrl || null;
|
|
8744
|
-
}
|
|
8745
|
-
if (typeof firstPicture === 'string') {
|
|
8746
|
-
return firstPicture;
|
|
8747
|
-
}
|
|
8748
|
-
} else if (isPictureObject(value)) {
|
|
8749
|
-
return value.thumbUrl || value.fullUrl || null;
|
|
8750
|
-
}
|
|
8751
|
-
return value;
|
|
8752
|
-
}, 'optimizePictureField');
|
|
8753
|
-
const visibilityOptions = ownership && uid ? { uid, ownership } : void 0;
|
|
8754
|
-
const docs = snapshot.docs.map((doc) => {
|
|
8755
|
-
const rawData = doc.data() || {};
|
|
8756
|
-
const visibleData = filterVisibleFields(
|
|
8757
|
-
rawData,
|
|
8758
|
-
documentSchema,
|
|
8759
|
-
userRole,
|
|
8760
|
-
visibilityOptions
|
|
8761
|
-
? { ...visibilityOptions, documentData: rawData }
|
|
8762
|
-
: void 0
|
|
8763
|
-
);
|
|
8764
|
-
if (listFields && listFields.length > 0) {
|
|
8765
|
-
const filtered = { id: doc.id };
|
|
8766
|
-
for (const field of listFields) {
|
|
8767
|
-
if (field in visibleData) {
|
|
8768
|
-
const value = visibleData[field];
|
|
8769
|
-
filtered[field] = optimizePictureField(value);
|
|
8770
|
-
}
|
|
8771
|
-
}
|
|
8772
|
-
return filtered;
|
|
8773
|
-
}
|
|
8774
|
-
const optimizedData = { id: doc.id };
|
|
8775
|
-
for (const [key, value] of Object.entries(visibleData)) {
|
|
8776
|
-
optimizedData[key] = optimizePictureField(value);
|
|
8777
|
-
}
|
|
8778
|
-
return optimizedData;
|
|
8779
|
-
});
|
|
7952
|
+
const docs = snapshot.docs.map((doc) => ({
|
|
7953
|
+
id: doc.id,
|
|
7954
|
+
...filterVisibleFields(doc.data() || {}, documentSchema, userRole),
|
|
7955
|
+
}));
|
|
8780
7956
|
return {
|
|
8781
7957
|
items: transformFirestoreData2(docs),
|
|
8782
7958
|
lastVisible: snapshot.docs[snapshot.docs.length - 1]?.id || null,
|
|
@@ -8787,21 +7963,13 @@ function listEntitiesLogicFactory(
|
|
|
8787
7963
|
}
|
|
8788
7964
|
__name(listEntitiesLogicFactory, 'listEntitiesLogicFactory');
|
|
8789
7965
|
var listEntities = /* @__PURE__ */ __name(
|
|
8790
|
-
(
|
|
8791
|
-
collection,
|
|
8792
|
-
documentSchema,
|
|
8793
|
-
requiredRole,
|
|
8794
|
-
customSchema,
|
|
8795
|
-
listFields,
|
|
8796
|
-
ownership,
|
|
8797
|
-
isListCard
|
|
8798
|
-
) => {
|
|
7966
|
+
(collection, documentSchema, customSchema) => {
|
|
8799
7967
|
const requestSchema =
|
|
8800
7968
|
customSchema ||
|
|
8801
7969
|
object({
|
|
8802
7970
|
where: optional(array(tuple([string(), any(), any()]))),
|
|
8803
7971
|
orderBy: optional(array(tuple([string(), picklist(['asc', 'desc'])]))),
|
|
8804
|
-
limit: optional(pipe(number(), minValue(1))),
|
|
7972
|
+
limit: optional(pipe(number(), minValue(1), maxValue(100))),
|
|
8805
7973
|
startAfterId: optional(string()),
|
|
8806
7974
|
search: optional(
|
|
8807
7975
|
object({
|
|
@@ -8811,17 +7979,10 @@ var listEntities = /* @__PURE__ */ __name(
|
|
|
8811
7979
|
),
|
|
8812
7980
|
});
|
|
8813
7981
|
return createBaseFunction(
|
|
8814
|
-
|
|
7982
|
+
CRUD_CONFIG,
|
|
8815
7983
|
requestSchema,
|
|
8816
7984
|
'list_entities',
|
|
8817
|
-
listEntitiesLogicFactory(
|
|
8818
|
-
collection,
|
|
8819
|
-
documentSchema,
|
|
8820
|
-
listFields,
|
|
8821
|
-
ownership,
|
|
8822
|
-
isListCard
|
|
8823
|
-
),
|
|
8824
|
-
requiredRole
|
|
7985
|
+
listEntitiesLogicFactory(collection, documentSchema)
|
|
8825
7986
|
);
|
|
8826
7987
|
},
|
|
8827
7988
|
'listEntities'
|
|
@@ -8829,76 +7990,15 @@ var listEntities = /* @__PURE__ */ __name(
|
|
|
8829
7990
|
|
|
8830
7991
|
// src/firebase/crud/update.ts
|
|
8831
7992
|
init_dist();
|
|
8832
|
-
|
|
7993
|
+
init_server4();
|
|
8833
7994
|
init_server3();
|
|
8834
|
-
function normalizeValue2(value) {
|
|
8835
|
-
if (typeof value === 'string') {
|
|
8836
|
-
return value.toLowerCase();
|
|
8837
|
-
}
|
|
8838
|
-
return value;
|
|
8839
|
-
}
|
|
8840
|
-
__name(normalizeValue2, 'normalizeValue');
|
|
8841
|
-
function normalizePayloadForUniqueKeys2(payload, uniqueKeys) {
|
|
8842
|
-
const normalized = { ...payload };
|
|
8843
|
-
for (const uniqueKey of uniqueKeys) {
|
|
8844
|
-
for (const field of uniqueKey.fields) {
|
|
8845
|
-
if (typeof normalized[field] === 'string') {
|
|
8846
|
-
normalized[field] = normalized[field].toLowerCase();
|
|
8847
|
-
}
|
|
8848
|
-
}
|
|
8849
|
-
}
|
|
8850
|
-
return normalized;
|
|
8851
|
-
}
|
|
8852
|
-
__name(normalizePayloadForUniqueKeys2, 'normalizePayloadForUniqueKeys');
|
|
8853
|
-
async function checkUniqueKeysForUpdate(
|
|
8854
|
-
collection,
|
|
8855
|
-
currentDocId,
|
|
8856
|
-
mergedData,
|
|
8857
|
-
payload,
|
|
8858
|
-
uniqueKeys,
|
|
8859
|
-
isDraft
|
|
8860
|
-
) {
|
|
8861
|
-
const db = getFirebaseAdminFirestore();
|
|
8862
|
-
for (const uniqueKey of uniqueKeys) {
|
|
8863
|
-
const skipForDrafts = uniqueKey.skipForDrafts !== false;
|
|
8864
|
-
if (isDraft && skipForDrafts) continue;
|
|
8865
|
-
const isUpdatingUniqueKeyField = uniqueKey.fields.some(
|
|
8866
|
-
(field) => field in payload
|
|
8867
|
-
);
|
|
8868
|
-
if (!isUpdatingUniqueKeyField) continue;
|
|
8869
|
-
const allFieldsHaveValues = uniqueKey.fields.every(
|
|
8870
|
-
(field) => mergedData[field] != null && mergedData[field] !== ''
|
|
8871
|
-
);
|
|
8872
|
-
if (!allFieldsHaveValues) continue;
|
|
8873
|
-
let query = db.collection(collection);
|
|
8874
|
-
for (const field of uniqueKey.fields) {
|
|
8875
|
-
query = query.where(field, '==', normalizeValue2(mergedData[field]));
|
|
8876
|
-
}
|
|
8877
|
-
const existing = await query.limit(2).get();
|
|
8878
|
-
const conflictingDoc = existing.docs.find((doc) => doc.id !== currentDocId);
|
|
8879
|
-
if (conflictingDoc) {
|
|
8880
|
-
const fieldNames = uniqueKey.fields.join(' + ');
|
|
8881
|
-
throw new DoNotDevError(
|
|
8882
|
-
uniqueKey.errorMessage || `Duplicate ${fieldNames}`,
|
|
8883
|
-
'already-exists',
|
|
8884
|
-
{
|
|
8885
|
-
details: {
|
|
8886
|
-
fields: uniqueKey.fields,
|
|
8887
|
-
existingId: conflictingDoc.id,
|
|
8888
|
-
},
|
|
8889
|
-
}
|
|
8890
|
-
);
|
|
8891
|
-
}
|
|
8892
|
-
}
|
|
8893
|
-
}
|
|
8894
|
-
__name(checkUniqueKeysForUpdate, 'checkUniqueKeysForUpdate');
|
|
8895
7995
|
function updateEntityLogicFactory(collection, documentSchema) {
|
|
8896
7996
|
return /* @__PURE__ */ __name(async function updateEntityLogic(
|
|
8897
7997
|
data,
|
|
8898
7998
|
context
|
|
8899
7999
|
) {
|
|
8900
8000
|
const { id, payload, idempotencyKey } = data;
|
|
8901
|
-
const
|
|
8001
|
+
const uid = await assertAdmin(context.uid);
|
|
8902
8002
|
if (idempotencyKey) {
|
|
8903
8003
|
const db2 = getFirebaseAdminFirestore();
|
|
8904
8004
|
const idempotencyRef = db2
|
|
@@ -8919,27 +8019,11 @@ function updateEntityLogicFactory(collection, documentSchema) {
|
|
|
8919
8019
|
const mergedData = { ...currentData, ...payload };
|
|
8920
8020
|
const resultingStatus = mergedData.status ?? DEFAULT_STATUS_VALUE;
|
|
8921
8021
|
const isDraft = resultingStatus === 'draft';
|
|
8922
|
-
const schemaWithMeta = documentSchema;
|
|
8923
|
-
const uniqueKeys = schemaWithMeta.metadata?.uniqueKeys;
|
|
8924
|
-
if (uniqueKeys && uniqueKeys.length > 0) {
|
|
8925
|
-
await checkUniqueKeysForUpdate(
|
|
8926
|
-
collection,
|
|
8927
|
-
id,
|
|
8928
|
-
mergedData,
|
|
8929
|
-
payload,
|
|
8930
|
-
uniqueKeys,
|
|
8931
|
-
isDraft
|
|
8932
|
-
);
|
|
8933
|
-
}
|
|
8934
8022
|
if (!isDraft) {
|
|
8935
8023
|
validateDocument(mergedData, documentSchema);
|
|
8936
8024
|
}
|
|
8937
|
-
const normalizedPayload =
|
|
8938
|
-
uniqueKeys && uniqueKeys.length > 0
|
|
8939
|
-
? normalizePayloadForUniqueKeys2(payload, uniqueKeys)
|
|
8940
|
-
: payload;
|
|
8941
8025
|
const updateData = {
|
|
8942
|
-
...prepareForFirestore2(
|
|
8026
|
+
...prepareForFirestore2(payload),
|
|
8943
8027
|
...updateMetadata(uid),
|
|
8944
8028
|
};
|
|
8945
8029
|
await docRef.update(updateData);
|
|
@@ -8963,7 +8047,7 @@ function updateEntityLogicFactory(collection, documentSchema) {
|
|
|
8963
8047
|
}
|
|
8964
8048
|
__name(updateEntityLogicFactory, 'updateEntityLogicFactory');
|
|
8965
8049
|
var updateEntity = /* @__PURE__ */ __name(
|
|
8966
|
-
(collection, documentSchema,
|
|
8050
|
+
(collection, documentSchema, customSchema) => {
|
|
8967
8051
|
const requestSchema =
|
|
8968
8052
|
customSchema ||
|
|
8969
8053
|
object({
|
|
@@ -8975,15 +8059,14 @@ var updateEntity = /* @__PURE__ */ __name(
|
|
|
8975
8059
|
CRUD_CONFIG,
|
|
8976
8060
|
requestSchema,
|
|
8977
8061
|
'update_entity',
|
|
8978
|
-
updateEntityLogicFactory(collection, documentSchema)
|
|
8979
|
-
requiredRole
|
|
8062
|
+
updateEntityLogicFactory(collection, documentSchema)
|
|
8980
8063
|
);
|
|
8981
8064
|
},
|
|
8982
8065
|
'updateEntity'
|
|
8983
8066
|
);
|
|
8984
8067
|
|
|
8985
8068
|
// src/firebase/helpers/githubAccessHelper.ts
|
|
8986
|
-
|
|
8069
|
+
init_server4();
|
|
8987
8070
|
import { logger as logger8 } from 'firebase-functions/v2';
|
|
8988
8071
|
async function grantGitHubAccessHelper(
|
|
8989
8072
|
userId,
|
|
@@ -9095,7 +8178,7 @@ async function setCustomClaimsHelper(userId, claims, merge = true) {
|
|
|
9095
8178
|
__name(setCustomClaimsHelper, 'setCustomClaimsHelper');
|
|
9096
8179
|
|
|
9097
8180
|
// src/firebase/helpers/githubTeamAccessHelper.ts
|
|
9098
|
-
|
|
8181
|
+
init_server4();
|
|
9099
8182
|
import { logger as logger9 } from 'firebase-functions/v2';
|
|
9100
8183
|
async function grantGitHubTeamAccessHelper(
|
|
9101
8184
|
userId,
|
|
@@ -9254,7 +8337,7 @@ async function checkGitHubTeamAccessHelper(userId, githubUsername, teamConfig) {
|
|
|
9254
8337
|
__name(checkGitHubTeamAccessHelper, 'checkGitHubTeamAccessHelper');
|
|
9255
8338
|
|
|
9256
8339
|
// src/firebase/oauth/disconnect.ts
|
|
9257
|
-
|
|
8340
|
+
init_server4();
|
|
9258
8341
|
init_server3();
|
|
9259
8342
|
import {
|
|
9260
8343
|
onCall as onCall2,
|
|
@@ -9321,7 +8404,7 @@ async function revokeToken(provider, accessToken) {
|
|
|
9321
8404
|
__name(revokeToken, 'revokeToken');
|
|
9322
8405
|
|
|
9323
8406
|
// src/firebase/oauth/exchangeToken.ts
|
|
9324
|
-
|
|
8407
|
+
init_server4();
|
|
9325
8408
|
init_server3();
|
|
9326
8409
|
import {
|
|
9327
8410
|
onCall as onCall3,
|
|
@@ -9495,7 +8578,7 @@ async function saveOAuthConnection(data) {
|
|
|
9495
8578
|
__name(saveOAuthConnection, 'saveOAuthConnection');
|
|
9496
8579
|
|
|
9497
8580
|
// src/firebase/oauth/getConnections.ts
|
|
9498
|
-
|
|
8581
|
+
init_server4();
|
|
9499
8582
|
import {
|
|
9500
8583
|
onCall as onCall4,
|
|
9501
8584
|
HttpsError as HttpsError4,
|
|
@@ -9546,8 +8629,8 @@ var getConnections = onCall4(async (request) => {
|
|
|
9546
8629
|
});
|
|
9547
8630
|
|
|
9548
8631
|
// src/firebase/oauth/githubAccess.ts
|
|
8632
|
+
init_server4();
|
|
9549
8633
|
init_dist();
|
|
9550
|
-
init_server2();
|
|
9551
8634
|
init_server3();
|
|
9552
8635
|
import { logger as logger10 } from 'firebase-functions/v2';
|
|
9553
8636
|
import { onCall as onCall5 } from 'firebase-functions/v2/https';
|
|
@@ -9752,7 +8835,7 @@ async function checkGitHubAccessWithSchema(request, customSchema) {
|
|
|
9752
8835
|
__name(checkGitHubAccessWithSchema, 'checkGitHubAccessWithSchema');
|
|
9753
8836
|
|
|
9754
8837
|
// src/firebase/oauth/refreshToken.ts
|
|
9755
|
-
|
|
8838
|
+
init_server4();
|
|
9756
8839
|
init_server3();
|
|
9757
8840
|
import {
|
|
9758
8841
|
onCall as onCall6,
|
|
@@ -9858,7 +8941,7 @@ var refreshToken = onCall6(async (request) => {
|
|
|
9858
8941
|
});
|
|
9859
8942
|
|
|
9860
8943
|
// src/firebase/scheduled/checkExpiredSubscriptions.ts
|
|
9861
|
-
|
|
8944
|
+
init_server4();
|
|
9862
8945
|
import { logger as logger11 } from 'firebase-functions/v2';
|
|
9863
8946
|
import { onSchedule } from 'firebase-functions/v2/scheduler';
|
|
9864
8947
|
var checkExpiredSubscriptions = onSchedule(
|
|
@@ -9946,62 +9029,24 @@ async function revokeExpiredSubscription(userId, subscription) {
|
|
|
9946
9029
|
__name(revokeExpiredSubscription, 'revokeExpiredSubscription');
|
|
9947
9030
|
|
|
9948
9031
|
// src/firebase/registerCrudFunctions.ts
|
|
9949
|
-
|
|
9950
|
-
function
|
|
9032
|
+
init_server3();
|
|
9033
|
+
function registerCrudFunctions(
|
|
9034
|
+
entities,
|
|
9035
|
+
target = module.exports,
|
|
9036
|
+
options = {}
|
|
9037
|
+
) {
|
|
9951
9038
|
const { prefix = '' } = options;
|
|
9952
|
-
const functions = {};
|
|
9953
9039
|
for (const [key, value] of Object.entries(entities)) {
|
|
9954
9040
|
if (!isEntity(value)) continue;
|
|
9955
9041
|
const entity = value;
|
|
9956
9042
|
const col = entity.collection;
|
|
9957
9043
|
const schemas = createSchemas(entity);
|
|
9958
|
-
|
|
9959
|
-
|
|
9960
|
-
|
|
9961
|
-
|
|
9962
|
-
|
|
9963
|
-
);
|
|
9964
|
-
functions[`${prefix}get_${col}`] = getEntity(
|
|
9965
|
-
col,
|
|
9966
|
-
schemas.get,
|
|
9967
|
-
access.read,
|
|
9968
|
-
void 0,
|
|
9969
|
-
entity.ownership
|
|
9970
|
-
);
|
|
9971
|
-
functions[`${prefix}list_${col}`] = listEntities(
|
|
9972
|
-
col,
|
|
9973
|
-
schemas.get,
|
|
9974
|
-
access.read,
|
|
9975
|
-
void 0,
|
|
9976
|
-
entity.listFields,
|
|
9977
|
-
entity.ownership,
|
|
9978
|
-
false
|
|
9979
|
-
);
|
|
9980
|
-
functions[`${prefix}listCard_${col}`] = listEntities(
|
|
9981
|
-
col,
|
|
9982
|
-
schemas.get,
|
|
9983
|
-
access.read,
|
|
9984
|
-
void 0,
|
|
9985
|
-
entity.listCardFields ?? entity.listFields ?? void 0,
|
|
9986
|
-
entity.ownership,
|
|
9987
|
-
true
|
|
9988
|
-
);
|
|
9989
|
-
functions[`${prefix}update_${col}`] = updateEntity(
|
|
9990
|
-
col,
|
|
9991
|
-
schemas.update,
|
|
9992
|
-
access.update
|
|
9993
|
-
);
|
|
9994
|
-
functions[`${prefix}delete_${col}`] = deleteEntity(col, access.delete);
|
|
9995
|
-
}
|
|
9996
|
-
return functions;
|
|
9997
|
-
}
|
|
9998
|
-
__name(createCrudFunctions, 'createCrudFunctions');
|
|
9999
|
-
function registerCrudFunctions(entities, target, options = {}) {
|
|
10000
|
-
const functions = createCrudFunctions(entities, options);
|
|
10001
|
-
if (target) {
|
|
10002
|
-
Object.assign(target, functions);
|
|
9044
|
+
target[`${prefix}create_${col}`] = createEntity(col, schemas.create);
|
|
9045
|
+
target[`${prefix}get_${col}`] = getEntity(col, schemas.get);
|
|
9046
|
+
target[`${prefix}list_${col}`] = listEntities(col, schemas.list);
|
|
9047
|
+
target[`${prefix}update_${col}`] = updateEntity(col, schemas.update);
|
|
9048
|
+
target[`${prefix}delete_${col}`] = deleteEntity(col, schemas.delete);
|
|
10003
9049
|
}
|
|
10004
|
-
return functions;
|
|
10005
9050
|
}
|
|
10006
9051
|
__name(registerCrudFunctions, 'registerCrudFunctions');
|
|
10007
9052
|
function isEntity(value) {
|
|
@@ -10017,7 +9062,6 @@ export {
|
|
|
10017
9062
|
AUTH_CONFIG,
|
|
10018
9063
|
AVAILABLE_REGIONS,
|
|
10019
9064
|
CRUD_CONFIG,
|
|
10020
|
-
CRUD_READ_CONFIG,
|
|
10021
9065
|
FIREBASE_REGION,
|
|
10022
9066
|
FUNCTION_CONFIG,
|
|
10023
9067
|
STRIPE_CONFIG,
|
|
@@ -10031,7 +9075,6 @@ export {
|
|
|
10031
9075
|
checkGitHubTeamAccessHelper,
|
|
10032
9076
|
createBaseFunction,
|
|
10033
9077
|
createCheckoutSession,
|
|
10034
|
-
createCrudFunctions,
|
|
10035
9078
|
createCustomerPortal,
|
|
10036
9079
|
createEntity,
|
|
10037
9080
|
createIdempotencyStore,
|