@timardex/cluemart-server-shared 1.0.163 → 1.0.165
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/dist/{chunk-RGSAG3WZ.mjs → chunk-5F477CH2.mjs} +178 -149
- package/dist/chunk-5F477CH2.mjs.map +1 -0
- package/dist/index.cjs +269 -221
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.mjs +267 -220
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +179 -149
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.d.mts +13 -2
- package/dist/mongoose/index.d.ts +13 -2
- package/dist/mongoose/index.mjs +3 -1
- package/dist/service/index.cjs +263 -217
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.mjs +83 -65
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-RGSAG3WZ.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -4677,10 +4677,10 @@ var Condition = class _Condition {
|
|
|
4677
4677
|
otherwise
|
|
4678
4678
|
} = config;
|
|
4679
4679
|
let check = typeof is === "function" ? is : (...values) => values.every((value) => value === is);
|
|
4680
|
-
return new _Condition(refs, (values,
|
|
4680
|
+
return new _Condition(refs, (values, schema17) => {
|
|
4681
4681
|
var _branch;
|
|
4682
4682
|
let branch = check(...values) ? then : otherwise;
|
|
4683
|
-
return (_branch = branch == null ? void 0 : branch(
|
|
4683
|
+
return (_branch = branch == null ? void 0 : branch(schema17)) != null ? _branch : schema17;
|
|
4684
4684
|
});
|
|
4685
4685
|
}
|
|
4686
4686
|
constructor(refs, builder) {
|
|
@@ -4694,13 +4694,13 @@ var Condition = class _Condition {
|
|
|
4694
4694
|
// TODO: ? operator here?
|
|
4695
4695
|
ref.getValue(options == null ? void 0 : options.value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context)
|
|
4696
4696
|
));
|
|
4697
|
-
let
|
|
4698
|
-
if (
|
|
4699
|
-
|
|
4697
|
+
let schema17 = this.fn(values, base, options);
|
|
4698
|
+
if (schema17 === void 0 || // @ts-ignore this can be base
|
|
4699
|
+
schema17 === base) {
|
|
4700
4700
|
return base;
|
|
4701
4701
|
}
|
|
4702
|
-
if (!isSchema(
|
|
4703
|
-
return
|
|
4702
|
+
if (!isSchema(schema17)) throw new TypeError("conditions must return a schema object");
|
|
4703
|
+
return schema17.resolve(options);
|
|
4704
4704
|
}
|
|
4705
4705
|
};
|
|
4706
4706
|
var prefixes = {
|
|
@@ -4770,7 +4770,7 @@ function createValidation(config) {
|
|
|
4770
4770
|
path = "",
|
|
4771
4771
|
options,
|
|
4772
4772
|
originalValue,
|
|
4773
|
-
schema:
|
|
4773
|
+
schema: schema17
|
|
4774
4774
|
}, panic, next) {
|
|
4775
4775
|
const {
|
|
4776
4776
|
name,
|
|
@@ -4782,8 +4782,8 @@ function createValidation(config) {
|
|
|
4782
4782
|
let {
|
|
4783
4783
|
parent,
|
|
4784
4784
|
context,
|
|
4785
|
-
abortEarly =
|
|
4786
|
-
disableStackTrace =
|
|
4785
|
+
abortEarly = schema17.spec.abortEarly,
|
|
4786
|
+
disableStackTrace = schema17.spec.disableStackTrace
|
|
4787
4787
|
} = options;
|
|
4788
4788
|
function resolve(item) {
|
|
4789
4789
|
return Reference.isRef(item) ? item.getValue(value, parent, context) : item;
|
|
@@ -4792,9 +4792,9 @@ function createValidation(config) {
|
|
|
4792
4792
|
const nextParams = Object.assign({
|
|
4793
4793
|
value,
|
|
4794
4794
|
originalValue,
|
|
4795
|
-
label:
|
|
4795
|
+
label: schema17.spec.label,
|
|
4796
4796
|
path: overrides.path || path,
|
|
4797
|
-
spec:
|
|
4797
|
+
spec: schema17.spec,
|
|
4798
4798
|
disableStackTrace: overrides.disableStackTrace || disableStackTrace
|
|
4799
4799
|
}, params, overrides.params);
|
|
4800
4800
|
for (const key of Object.keys(nextParams)) nextParams[key] = resolve(nextParams[key]);
|
|
@@ -4812,7 +4812,7 @@ function createValidation(config) {
|
|
|
4812
4812
|
resolve,
|
|
4813
4813
|
options,
|
|
4814
4814
|
originalValue,
|
|
4815
|
-
schema:
|
|
4815
|
+
schema: schema17
|
|
4816
4816
|
};
|
|
4817
4817
|
const handleResult = (validOrError) => {
|
|
4818
4818
|
if (ValidationError.isError(validOrError)) invalid(validOrError);
|
|
@@ -4846,42 +4846,42 @@ function createValidation(config) {
|
|
|
4846
4846
|
validate.OPTIONS = config;
|
|
4847
4847
|
return validate;
|
|
4848
4848
|
}
|
|
4849
|
-
function getIn(
|
|
4849
|
+
function getIn(schema17, path, value, context = value) {
|
|
4850
4850
|
let parent, lastPart, lastPartDebug;
|
|
4851
4851
|
if (!path) return {
|
|
4852
4852
|
parent,
|
|
4853
4853
|
parentPath: path,
|
|
4854
|
-
schema:
|
|
4854
|
+
schema: schema17
|
|
4855
4855
|
};
|
|
4856
4856
|
(0, import_property_expr.forEach)(path, (_part, isBracket, isArray) => {
|
|
4857
4857
|
let part = isBracket ? _part.slice(1, _part.length - 1) : _part;
|
|
4858
|
-
|
|
4858
|
+
schema17 = schema17.resolve({
|
|
4859
4859
|
context,
|
|
4860
4860
|
parent,
|
|
4861
4861
|
value
|
|
4862
4862
|
});
|
|
4863
|
-
let isTuple =
|
|
4863
|
+
let isTuple = schema17.type === "tuple";
|
|
4864
4864
|
let idx = isArray ? parseInt(part, 10) : 0;
|
|
4865
|
-
if (
|
|
4865
|
+
if (schema17.innerType || isTuple) {
|
|
4866
4866
|
if (isTuple && !isArray) throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${lastPartDebug}" must contain an index to the tuple element, e.g. "${lastPartDebug}[0]"`);
|
|
4867
4867
|
if (value && idx >= value.length) {
|
|
4868
4868
|
throw new Error(`Yup.reach cannot resolve an array item at index: ${_part}, in the path: ${path}. because there is no value at that index. `);
|
|
4869
4869
|
}
|
|
4870
4870
|
parent = value;
|
|
4871
4871
|
value = value && value[idx];
|
|
4872
|
-
|
|
4872
|
+
schema17 = isTuple ? schema17.spec.types[idx] : schema17.innerType;
|
|
4873
4873
|
}
|
|
4874
4874
|
if (!isArray) {
|
|
4875
|
-
if (!
|
|
4875
|
+
if (!schema17.fields || !schema17.fields[part]) throw new Error(`The schema does not contain the path: ${path}. (failed at: ${lastPartDebug} which is a type: "${schema17.type}")`);
|
|
4876
4876
|
parent = value;
|
|
4877
4877
|
value = value && value[part];
|
|
4878
|
-
|
|
4878
|
+
schema17 = schema17.fields[part];
|
|
4879
4879
|
}
|
|
4880
4880
|
lastPart = part;
|
|
4881
4881
|
lastPartDebug = isBracket ? "[" + _part + "]" : "." + _part;
|
|
4882
4882
|
});
|
|
4883
4883
|
return {
|
|
4884
|
-
schema:
|
|
4884
|
+
schema: schema17,
|
|
4885
4885
|
parent,
|
|
4886
4886
|
parentPath: lastPart
|
|
4887
4887
|
};
|
|
@@ -5018,20 +5018,20 @@ var Schema = class {
|
|
|
5018
5018
|
this._mutate = before;
|
|
5019
5019
|
return result;
|
|
5020
5020
|
}
|
|
5021
|
-
concat(
|
|
5022
|
-
if (!
|
|
5023
|
-
if (
|
|
5021
|
+
concat(schema17) {
|
|
5022
|
+
if (!schema17 || schema17 === this) return this;
|
|
5023
|
+
if (schema17.type !== this.type && this.type !== "mixed") throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${schema17.type}`);
|
|
5024
5024
|
let base = this;
|
|
5025
|
-
let combined =
|
|
5025
|
+
let combined = schema17.clone();
|
|
5026
5026
|
const mergedSpec = Object.assign({}, base.spec, combined.spec);
|
|
5027
5027
|
combined.spec = mergedSpec;
|
|
5028
5028
|
combined.internalTests = Object.assign({}, base.internalTests, combined.internalTests);
|
|
5029
|
-
combined._whitelist = base._whitelist.merge(
|
|
5030
|
-
combined._blacklist = base._blacklist.merge(
|
|
5029
|
+
combined._whitelist = base._whitelist.merge(schema17._whitelist, schema17._blacklist);
|
|
5030
|
+
combined._blacklist = base._blacklist.merge(schema17._blacklist, schema17._whitelist);
|
|
5031
5031
|
combined.tests = base.tests;
|
|
5032
5032
|
combined.exclusiveTests = base.exclusiveTests;
|
|
5033
5033
|
combined.withMutation((next) => {
|
|
5034
|
-
|
|
5034
|
+
schema17.tests.forEach((fn) => {
|
|
5035
5035
|
next.test(fn.OPTIONS);
|
|
5036
5036
|
});
|
|
5037
5037
|
});
|
|
@@ -5047,15 +5047,15 @@ var Schema = class {
|
|
|
5047
5047
|
return this._typeCheck(v);
|
|
5048
5048
|
}
|
|
5049
5049
|
resolve(options) {
|
|
5050
|
-
let
|
|
5051
|
-
if (
|
|
5052
|
-
let conditions =
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5050
|
+
let schema17 = this;
|
|
5051
|
+
if (schema17.conditions.length) {
|
|
5052
|
+
let conditions = schema17.conditions;
|
|
5053
|
+
schema17 = schema17.clone();
|
|
5054
|
+
schema17.conditions = [];
|
|
5055
|
+
schema17 = conditions.reduce((prevSchema, condition) => condition.resolve(prevSchema, options), schema17);
|
|
5056
|
+
schema17 = schema17.resolve(options);
|
|
5057
5057
|
}
|
|
5058
|
-
return
|
|
5058
|
+
return schema17;
|
|
5059
5059
|
}
|
|
5060
5060
|
resolveOptions(options) {
|
|
5061
5061
|
var _options$strict, _options$abortEarly, _options$recursive, _options$disableStack;
|
|
@@ -5209,11 +5209,11 @@ attempted value: ${formattedValue}
|
|
|
5209
5209
|
}
|
|
5210
5210
|
validate(value, options) {
|
|
5211
5211
|
var _options$disableStack2;
|
|
5212
|
-
let
|
|
5212
|
+
let schema17 = this.resolve(Object.assign({}, options, {
|
|
5213
5213
|
value
|
|
5214
5214
|
}));
|
|
5215
|
-
let disableStackTrace = (_options$disableStack2 = options == null ? void 0 : options.disableStackTrace) != null ? _options$disableStack2 :
|
|
5216
|
-
return new Promise((resolve, reject) =>
|
|
5215
|
+
let disableStackTrace = (_options$disableStack2 = options == null ? void 0 : options.disableStackTrace) != null ? _options$disableStack2 : schema17.spec.disableStackTrace;
|
|
5216
|
+
return new Promise((resolve, reject) => schema17._validate(value, options, (error, parsed) => {
|
|
5217
5217
|
if (ValidationError.isError(error)) error.value = parsed;
|
|
5218
5218
|
reject(error);
|
|
5219
5219
|
}, (errors, validated) => {
|
|
@@ -5223,12 +5223,12 @@ attempted value: ${formattedValue}
|
|
|
5223
5223
|
}
|
|
5224
5224
|
validateSync(value, options) {
|
|
5225
5225
|
var _options$disableStack3;
|
|
5226
|
-
let
|
|
5226
|
+
let schema17 = this.resolve(Object.assign({}, options, {
|
|
5227
5227
|
value
|
|
5228
5228
|
}));
|
|
5229
5229
|
let result;
|
|
5230
|
-
let disableStackTrace = (_options$disableStack3 = options == null ? void 0 : options.disableStackTrace) != null ? _options$disableStack3 :
|
|
5231
|
-
|
|
5230
|
+
let disableStackTrace = (_options$disableStack3 = options == null ? void 0 : options.disableStackTrace) != null ? _options$disableStack3 : schema17.spec.disableStackTrace;
|
|
5231
|
+
schema17._validate(value, Object.assign({}, options, {
|
|
5232
5232
|
sync: true
|
|
5233
5233
|
}), (error, parsed) => {
|
|
5234
5234
|
if (ValidationError.isError(error)) error.value = parsed;
|
|
@@ -5262,8 +5262,8 @@ attempted value: ${formattedValue}
|
|
|
5262
5262
|
return typeof defaultValue === "function" ? defaultValue.call(this, options) : clone(defaultValue);
|
|
5263
5263
|
}
|
|
5264
5264
|
getDefault(options) {
|
|
5265
|
-
let
|
|
5266
|
-
return
|
|
5265
|
+
let schema17 = this.resolve(options || {});
|
|
5266
|
+
return schema17._getDefault(options);
|
|
5267
5267
|
}
|
|
5268
5268
|
default(def) {
|
|
5269
5269
|
if (arguments.length === 0) {
|
|
@@ -5498,9 +5498,9 @@ for (const method of ["validate", "validateSync"]) Schema.prototype[`${method}At
|
|
|
5498
5498
|
const {
|
|
5499
5499
|
parent,
|
|
5500
5500
|
parentPath,
|
|
5501
|
-
schema:
|
|
5501
|
+
schema: schema17
|
|
5502
5502
|
} = getIn(this, path, value, options.context);
|
|
5503
|
-
return
|
|
5503
|
+
return schema17[method](parent && parent[parentPath], Object.assign({}, options, {
|
|
5504
5504
|
parent,
|
|
5505
5505
|
path
|
|
5506
5506
|
}));
|
|
@@ -5674,7 +5674,7 @@ var StringSchema = class extends Schema {
|
|
|
5674
5674
|
});
|
|
5675
5675
|
}
|
|
5676
5676
|
required(message) {
|
|
5677
|
-
return super.required(message).withMutation((
|
|
5677
|
+
return super.required(message).withMutation((schema17) => schema17.test({
|
|
5678
5678
|
message: message || mixed.required,
|
|
5679
5679
|
name: "required",
|
|
5680
5680
|
skipAbsent: true,
|
|
@@ -5682,9 +5682,9 @@ var StringSchema = class extends Schema {
|
|
|
5682
5682
|
}));
|
|
5683
5683
|
}
|
|
5684
5684
|
notRequired() {
|
|
5685
|
-
return super.notRequired().withMutation((
|
|
5686
|
-
|
|
5687
|
-
return
|
|
5685
|
+
return super.notRequired().withMutation((schema17) => {
|
|
5686
|
+
schema17.tests = schema17.tests.filter((t) => t.OPTIONS.name !== "required");
|
|
5687
|
+
return schema17;
|
|
5688
5688
|
});
|
|
5689
5689
|
}
|
|
5690
5690
|
length(length, message = string.length) {
|
|
@@ -6073,28 +6073,28 @@ var parseJson = (value, _, ctx) => {
|
|
|
6073
6073
|
}
|
|
6074
6074
|
return ctx.isType(parsed) ? parsed : value;
|
|
6075
6075
|
};
|
|
6076
|
-
function deepPartial(
|
|
6077
|
-
if ("fields" in
|
|
6076
|
+
function deepPartial(schema17) {
|
|
6077
|
+
if ("fields" in schema17) {
|
|
6078
6078
|
const partial = {};
|
|
6079
|
-
for (const [key, fieldSchema] of Object.entries(
|
|
6079
|
+
for (const [key, fieldSchema] of Object.entries(schema17.fields)) {
|
|
6080
6080
|
partial[key] = deepPartial(fieldSchema);
|
|
6081
6081
|
}
|
|
6082
|
-
return
|
|
6082
|
+
return schema17.setFields(partial);
|
|
6083
6083
|
}
|
|
6084
|
-
if (
|
|
6085
|
-
const nextArray =
|
|
6084
|
+
if (schema17.type === "array") {
|
|
6085
|
+
const nextArray = schema17.optional();
|
|
6086
6086
|
if (nextArray.innerType) nextArray.innerType = deepPartial(nextArray.innerType);
|
|
6087
6087
|
return nextArray;
|
|
6088
6088
|
}
|
|
6089
|
-
if (
|
|
6090
|
-
return
|
|
6091
|
-
types:
|
|
6089
|
+
if (schema17.type === "tuple") {
|
|
6090
|
+
return schema17.optional().clone({
|
|
6091
|
+
types: schema17.spec.types.map(deepPartial)
|
|
6092
6092
|
});
|
|
6093
6093
|
}
|
|
6094
|
-
if ("optional" in
|
|
6095
|
-
return
|
|
6094
|
+
if ("optional" in schema17) {
|
|
6095
|
+
return schema17.optional();
|
|
6096
6096
|
}
|
|
6097
|
-
return
|
|
6097
|
+
return schema17;
|
|
6098
6098
|
}
|
|
6099
6099
|
var deepHas = (obj, p) => {
|
|
6100
6100
|
const path = [...(0, import_property_expr.normalizePath)(p)];
|
|
@@ -6228,8 +6228,8 @@ var ObjectSchema = class extends Schema {
|
|
|
6228
6228
|
next._sortErrors = this._sortErrors;
|
|
6229
6229
|
return next;
|
|
6230
6230
|
}
|
|
6231
|
-
concat(
|
|
6232
|
-
let next = super.concat(
|
|
6231
|
+
concat(schema17) {
|
|
6232
|
+
let next = super.concat(schema17);
|
|
6233
6233
|
let nextFields = next.fields;
|
|
6234
6234
|
for (let [field, schemaOrRef] of Object.entries(this.fields)) {
|
|
6235
6235
|
const target = nextFields[field];
|
|
@@ -6237,7 +6237,7 @@ var ObjectSchema = class extends Schema {
|
|
|
6237
6237
|
}
|
|
6238
6238
|
return next.withMutation((s) => (
|
|
6239
6239
|
// XXX: excludes here is wrong
|
|
6240
|
-
s.setFields(nextFields, [...this._excludedEdges, ...
|
|
6240
|
+
s.setFields(nextFields, [...this._excludedEdges, ...schema17._excludedEdges])
|
|
6241
6241
|
));
|
|
6242
6242
|
}
|
|
6243
6243
|
_getDefault(options) {
|
|
@@ -6282,8 +6282,8 @@ var ObjectSchema = class extends Schema {
|
|
|
6282
6282
|
}
|
|
6283
6283
|
partial() {
|
|
6284
6284
|
const partial = {};
|
|
6285
|
-
for (const [key,
|
|
6286
|
-
partial[key] = "optional" in
|
|
6285
|
+
for (const [key, schema17] of Object.entries(this.fields)) {
|
|
6286
|
+
partial[key] = "optional" in schema17 && schema17.optional instanceof Function ? schema17.optional() : schema17;
|
|
6287
6287
|
}
|
|
6288
6288
|
return this.setFields(partial);
|
|
6289
6289
|
}
|
|
@@ -6481,22 +6481,22 @@ var ArraySchema = class extends Schema {
|
|
|
6481
6481
|
json() {
|
|
6482
6482
|
return this.transform(parseJson);
|
|
6483
6483
|
}
|
|
6484
|
-
concat(
|
|
6485
|
-
let next = super.concat(
|
|
6484
|
+
concat(schema17) {
|
|
6485
|
+
let next = super.concat(schema17);
|
|
6486
6486
|
next.innerType = this.innerType;
|
|
6487
|
-
if (
|
|
6487
|
+
if (schema17.innerType)
|
|
6488
6488
|
next.innerType = next.innerType ? (
|
|
6489
6489
|
// @ts-expect-error Lazy doesn't have concat and will break
|
|
6490
|
-
next.innerType.concat(
|
|
6491
|
-
) :
|
|
6490
|
+
next.innerType.concat(schema17.innerType)
|
|
6491
|
+
) : schema17.innerType;
|
|
6492
6492
|
return next;
|
|
6493
6493
|
}
|
|
6494
|
-
of(
|
|
6494
|
+
of(schema17) {
|
|
6495
6495
|
let next = this.clone();
|
|
6496
|
-
if (!isSchema(
|
|
6497
|
-
next.innerType =
|
|
6496
|
+
if (!isSchema(schema17)) throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: " + printValue(schema17));
|
|
6497
|
+
next.innerType = schema17;
|
|
6498
6498
|
next.spec = Object.assign({}, next.spec, {
|
|
6499
|
-
types:
|
|
6499
|
+
types: schema17
|
|
6500
6500
|
});
|
|
6501
6501
|
return next;
|
|
6502
6502
|
}
|
|
@@ -6640,7 +6640,7 @@ var TupleSchema = class extends Schema {
|
|
|
6640
6640
|
describe(options) {
|
|
6641
6641
|
const next = (options ? this.resolve(options) : this).clone();
|
|
6642
6642
|
const base = super.describe(options);
|
|
6643
|
-
base.innerType = next.spec.types.map((
|
|
6643
|
+
base.innerType = next.spec.types.map((schema17, index) => {
|
|
6644
6644
|
var _innerOptions;
|
|
6645
6645
|
let innerOptions = options;
|
|
6646
6646
|
if ((_innerOptions = innerOptions) != null && _innerOptions.value) {
|
|
@@ -6649,7 +6649,7 @@ var TupleSchema = class extends Schema {
|
|
|
6649
6649
|
value: innerOptions.value[index]
|
|
6650
6650
|
});
|
|
6651
6651
|
}
|
|
6652
|
-
return
|
|
6652
|
+
return schema17.describe(innerOptions);
|
|
6653
6653
|
});
|
|
6654
6654
|
return base;
|
|
6655
6655
|
}
|
|
@@ -10542,7 +10542,7 @@ var stallTypesSchema = create$3({
|
|
|
10542
10542
|
"",
|
|
10543
10543
|
noLeadingZeros("Stall price", { allowDecimal: true })
|
|
10544
10544
|
),
|
|
10545
|
-
stallCapacity: create$5().label("Stall Capacity").typeError("Stall capacity must be a number").min(
|
|
10545
|
+
stallCapacity: create$5().label("Stall Capacity").typeError("Stall capacity must be a number").min(0, "Stall capacity cannot be negative").integer("Stall capacity must be a whole number").required("Stall capacity is required").test("no-leading-zeros", "", noLeadingZeros("Stall capacity"))
|
|
10546
10546
|
});
|
|
10547
10547
|
var dateTimeWithPriceSchema = dateTimeSchema.shape({
|
|
10548
10548
|
stallTypes: create$2().of(stallTypesSchema).min(1, "At least one stall type is required").required("Stall types are required")
|
|
@@ -10569,7 +10569,7 @@ var socialMediaSchema = create$3({
|
|
|
10569
10569
|
is: (name) => !!name,
|
|
10570
10570
|
// If name has a value
|
|
10571
10571
|
then: () => normalizedUrlTransform().required("Link is required when name is set").url("Link must be a valid URL").label("Social Media Link"),
|
|
10572
|
-
otherwise: (
|
|
10572
|
+
otherwise: (schema17) => schema17.notRequired()
|
|
10573
10573
|
})
|
|
10574
10574
|
});
|
|
10575
10575
|
var globalResourceSchema = create$3().shape({
|
|
@@ -10645,21 +10645,21 @@ var paymentInfoSchema = create$3({
|
|
|
10645
10645
|
).required("Please select a Payment method"),
|
|
10646
10646
|
accountHolderName: create$6().when("paymentMethod", {
|
|
10647
10647
|
is: "bank_transfer",
|
|
10648
|
-
then: (
|
|
10649
|
-
otherwise: (
|
|
10648
|
+
then: (schema17) => schema17.required("Account holder name is required for bank transfer").trim(),
|
|
10649
|
+
otherwise: (schema17) => schema17.notRequired()
|
|
10650
10650
|
}),
|
|
10651
10651
|
accountNumber: create$6().when("paymentMethod", {
|
|
10652
10652
|
is: "bank_transfer",
|
|
10653
|
-
then: (
|
|
10653
|
+
then: (schema17) => schema17.required("Account number is required for bank transfer").matches(
|
|
10654
10654
|
nzBankAccountRegex,
|
|
10655
10655
|
"Account number must be in format: XX-XXXX-XXXXXXX-XX"
|
|
10656
10656
|
).trim(),
|
|
10657
|
-
otherwise: (
|
|
10657
|
+
otherwise: (schema17) => schema17.notRequired()
|
|
10658
10658
|
}),
|
|
10659
10659
|
link: create$6().when("paymentMethod", {
|
|
10660
10660
|
is: (val) => val === "paypal" || val === "stripe",
|
|
10661
10661
|
then: () => normalizedUrlTransform().url("Link must be a valid URL").required("Link is required for PayPal/Stripe"),
|
|
10662
|
-
otherwise: (
|
|
10662
|
+
otherwise: (schema17) => schema17.notRequired()
|
|
10663
10663
|
})
|
|
10664
10664
|
});
|
|
10665
10665
|
var eventInfoSchema = create$3().shape({
|
|
@@ -10809,8 +10809,8 @@ var userSchema = create$3().shape({
|
|
|
10809
10809
|
confirmPassword: create$6().nullable().trim().label("Confirm Password").when("password", {
|
|
10810
10810
|
is: (val) => !!val,
|
|
10811
10811
|
// only necessary if password typed
|
|
10812
|
-
then: (
|
|
10813
|
-
otherwise: (
|
|
10812
|
+
then: (schema17) => schema17.required("Confirm Password is required").oneOf([create$9("password")], "Passwords must match"),
|
|
10813
|
+
otherwise: (schema17) => schema17.notRequired()
|
|
10814
10814
|
}),
|
|
10815
10815
|
role: create$8().oneOf(Object.values(EnumUserRole)).required("Role is required")
|
|
10816
10816
|
});
|
|
@@ -10881,7 +10881,7 @@ var adSchema = create$3().shape({
|
|
|
10881
10881
|
return endDate > now;
|
|
10882
10882
|
}).when("start", {
|
|
10883
10883
|
is: (val) => val && val.length > 0,
|
|
10884
|
-
then: (
|
|
10884
|
+
then: (schema17) => schema17.test(
|
|
10885
10885
|
"is-after-start",
|
|
10886
10886
|
"End date must be after start date",
|
|
10887
10887
|
function(value) {
|
|
@@ -12157,7 +12157,7 @@ var schema9 = new MongooseSchema13(
|
|
|
12157
12157
|
required: false,
|
|
12158
12158
|
type: calendarWrapperSchema
|
|
12159
12159
|
},
|
|
12160
|
-
categories: [CategorySchema],
|
|
12160
|
+
categories: { required: true, type: [CategorySchema] },
|
|
12161
12161
|
foodTruck: { required: true, type: Boolean },
|
|
12162
12162
|
products: { required: false, type: productWrapperSchema },
|
|
12163
12163
|
relations: {
|
|
@@ -12236,19 +12236,47 @@ var schema10 = new MongooseSchema14(
|
|
|
12236
12236
|
);
|
|
12237
12237
|
var VendorInfoModel = mongoose14.models.VendorInfo || mongoose14.model("VendorInfo", schema10);
|
|
12238
12238
|
|
|
12239
|
-
// src/mongoose/
|
|
12239
|
+
// src/mongoose/vendor/UnregisteredVendor.ts
|
|
12240
12240
|
import mongoose15 from "mongoose";
|
|
12241
12241
|
var MongooseSchema15 = mongoose15.Schema;
|
|
12242
|
+
var invitationSchema = new MongooseSchema15(
|
|
12243
|
+
{
|
|
12244
|
+
dateTime: { required: true, type: [dateTimeSchema3] },
|
|
12245
|
+
eventId: {
|
|
12246
|
+
ref: "Event",
|
|
12247
|
+
required: true,
|
|
12248
|
+
type: String
|
|
12249
|
+
}
|
|
12250
|
+
},
|
|
12251
|
+
{ _id: false }
|
|
12252
|
+
);
|
|
12242
12253
|
var schema11 = new MongooseSchema15(
|
|
12254
|
+
{
|
|
12255
|
+
categoryIds: { required: true, type: [String] },
|
|
12256
|
+
deletedAt: { default: null, required: false, type: Date },
|
|
12257
|
+
email: { required: true, type: String },
|
|
12258
|
+
invitations: { required: true, type: [invitationSchema] },
|
|
12259
|
+
name: { required: true, type: String }
|
|
12260
|
+
},
|
|
12261
|
+
{ timestamps: true }
|
|
12262
|
+
);
|
|
12263
|
+
schema11.index({ email: 1 }, { unique: true });
|
|
12264
|
+
schema11.index({ name: 1 });
|
|
12265
|
+
var UnregisteredVendorModel = mongoose15.models.UnregisteredVendor || mongoose15.model("UnregisteredVendor", schema11);
|
|
12266
|
+
|
|
12267
|
+
// src/mongoose/event/Event.ts
|
|
12268
|
+
import mongoose16 from "mongoose";
|
|
12269
|
+
var MongooseSchema16 = mongoose16.Schema;
|
|
12270
|
+
var schema12 = new MongooseSchema16(
|
|
12243
12271
|
{
|
|
12244
12272
|
...baseResourceFields,
|
|
12245
12273
|
// Importing base resource fields from global.ts
|
|
12246
12274
|
claimed: { default: true, required: false, type: Boolean },
|
|
12247
|
-
dateTime: [dateTimeSchema3],
|
|
12275
|
+
dateTime: { required: true, type: [dateTimeSchema3] },
|
|
12248
12276
|
eventInfoId: {
|
|
12249
12277
|
ref: "EventInfo",
|
|
12250
12278
|
required: false,
|
|
12251
|
-
type:
|
|
12279
|
+
type: mongoose16.Schema.Types.ObjectId
|
|
12252
12280
|
},
|
|
12253
12281
|
eventType: {
|
|
12254
12282
|
enum: Object.values(EnumEventType),
|
|
@@ -12277,18 +12305,18 @@ var schema11 = new MongooseSchema15(
|
|
|
12277
12305
|
},
|
|
12278
12306
|
{ timestamps: true }
|
|
12279
12307
|
);
|
|
12280
|
-
|
|
12281
|
-
|
|
12282
|
-
|
|
12283
|
-
|
|
12284
|
-
|
|
12285
|
-
|
|
12286
|
-
var EventModel =
|
|
12308
|
+
schema12.index({ name: 1 });
|
|
12309
|
+
schema12.index({ description: 1 });
|
|
12310
|
+
schema12.index({ region: 1 });
|
|
12311
|
+
schema12.index({ "location.geo": "2dsphere" });
|
|
12312
|
+
schema12.index({ tags: 1 });
|
|
12313
|
+
schema12.index({ "associates.email": 1 });
|
|
12314
|
+
var EventModel = mongoose16.models.Event || mongoose16.model("Event", schema12);
|
|
12287
12315
|
|
|
12288
12316
|
// src/mongoose/Partner.ts
|
|
12289
|
-
import
|
|
12290
|
-
var
|
|
12291
|
-
var
|
|
12317
|
+
import mongoose17 from "mongoose";
|
|
12318
|
+
var MongooseSchema17 = mongoose17.Schema;
|
|
12319
|
+
var schema13 = new MongooseSchema17(
|
|
12292
12320
|
{
|
|
12293
12321
|
...baseResourceFields,
|
|
12294
12322
|
location: {
|
|
@@ -12304,17 +12332,17 @@ var schema12 = new MongooseSchema16(
|
|
|
12304
12332
|
},
|
|
12305
12333
|
{ timestamps: true }
|
|
12306
12334
|
);
|
|
12307
|
-
|
|
12308
|
-
|
|
12309
|
-
|
|
12310
|
-
|
|
12311
|
-
|
|
12312
|
-
var PartnerModel =
|
|
12335
|
+
schema13.index({ name: 1 });
|
|
12336
|
+
schema13.index({ description: 1 });
|
|
12337
|
+
schema13.index({ region: 1 });
|
|
12338
|
+
schema13.index({ "location.geo": "2dsphere" });
|
|
12339
|
+
schema13.index({ "associates.email": 1 });
|
|
12340
|
+
var PartnerModel = mongoose17.models.Partner || mongoose17.model("Partner", schema13);
|
|
12313
12341
|
|
|
12314
12342
|
// src/mongoose/Post.ts
|
|
12315
|
-
import
|
|
12316
|
-
var
|
|
12317
|
-
var contentSchema = new
|
|
12343
|
+
import mongoose18, { Schema as Schema2 } from "mongoose";
|
|
12344
|
+
var MongooseSchema18 = mongoose18.Schema;
|
|
12345
|
+
var contentSchema = new MongooseSchema18(
|
|
12318
12346
|
{
|
|
12319
12347
|
contentData: Schema2.Types.Mixed,
|
|
12320
12348
|
contentOrder: { required: true, type: Number },
|
|
@@ -12326,7 +12354,7 @@ var contentSchema = new MongooseSchema17(
|
|
|
12326
12354
|
},
|
|
12327
12355
|
{ _id: false }
|
|
12328
12356
|
);
|
|
12329
|
-
var
|
|
12357
|
+
var schema14 = new MongooseSchema18(
|
|
12330
12358
|
{
|
|
12331
12359
|
active: { default: true, required: true, type: Boolean },
|
|
12332
12360
|
caption: { required: true, type: String },
|
|
@@ -12362,15 +12390,15 @@ var schema13 = new MongooseSchema17(
|
|
|
12362
12390
|
},
|
|
12363
12391
|
{ timestamps: true }
|
|
12364
12392
|
);
|
|
12365
|
-
|
|
12366
|
-
|
|
12367
|
-
var PostModel =
|
|
12393
|
+
schema14.index({ title: 1 });
|
|
12394
|
+
schema14.index({ tags: 1 });
|
|
12395
|
+
var PostModel = mongoose18.models.Post || mongoose18.model("Post", schema14);
|
|
12368
12396
|
|
|
12369
12397
|
// src/mongoose/AppSetting.ts
|
|
12370
|
-
import
|
|
12371
|
-
var
|
|
12398
|
+
import mongoose19 from "mongoose";
|
|
12399
|
+
var MongooseSchema19 = mongoose19.Schema;
|
|
12372
12400
|
var APP_SETTINGS_ID = "APP_SETTINGS_DOCUMENT_ID";
|
|
12373
|
-
var AppSettingSchema = new
|
|
12401
|
+
var AppSettingSchema = new MongooseSchema19(
|
|
12374
12402
|
{
|
|
12375
12403
|
activeSchoolsStudentCountTotal: {
|
|
12376
12404
|
default: 0,
|
|
@@ -12396,18 +12424,18 @@ var AppSettingSchema = new MongooseSchema18(
|
|
|
12396
12424
|
},
|
|
12397
12425
|
{ timestamps: true }
|
|
12398
12426
|
);
|
|
12399
|
-
var AppSettingModel =
|
|
12427
|
+
var AppSettingModel = mongoose19.models.AppSetting || mongoose19.model("AppSetting", AppSettingSchema);
|
|
12400
12428
|
|
|
12401
12429
|
// src/mongoose/game/Game.ts
|
|
12402
|
-
import
|
|
12430
|
+
import mongoose23 from "mongoose";
|
|
12403
12431
|
|
|
12404
12432
|
// src/mongoose/game/DailyClue.ts
|
|
12405
|
-
import
|
|
12433
|
+
import mongoose21 from "mongoose";
|
|
12406
12434
|
|
|
12407
12435
|
// src/mongoose/game/utils.ts
|
|
12408
|
-
import
|
|
12409
|
-
var
|
|
12410
|
-
var schemaGameDate = new
|
|
12436
|
+
import mongoose20 from "mongoose";
|
|
12437
|
+
var MongooseSchema20 = mongoose20.Schema;
|
|
12438
|
+
var schemaGameDate = new MongooseSchema20(
|
|
12411
12439
|
{
|
|
12412
12440
|
endDate: { required: true, type: Date },
|
|
12413
12441
|
startDate: { required: true, type: Date }
|
|
@@ -12416,8 +12444,8 @@ var schemaGameDate = new MongooseSchema19(
|
|
|
12416
12444
|
);
|
|
12417
12445
|
|
|
12418
12446
|
// src/mongoose/game/DailyClue.ts
|
|
12419
|
-
var
|
|
12420
|
-
var schemaLetters = new
|
|
12447
|
+
var MongooseSchema21 = mongoose21.Schema;
|
|
12448
|
+
var schemaLetters = new MongooseSchema21(
|
|
12421
12449
|
{
|
|
12422
12450
|
collected: { required: false, type: [String] },
|
|
12423
12451
|
solutionShuffled: { required: true, type: [String] }
|
|
@@ -12425,14 +12453,14 @@ var schemaLetters = new MongooseSchema20(
|
|
|
12425
12453
|
},
|
|
12426
12454
|
{ _id: false }
|
|
12427
12455
|
);
|
|
12428
|
-
var schemaDailyClueBaseGame = new
|
|
12456
|
+
var schemaDailyClueBaseGame = new MongooseSchema21(
|
|
12429
12457
|
{
|
|
12430
12458
|
gameDate: { required: true, type: schemaGameDate },
|
|
12431
12459
|
gameSolution: { required: true, type: String }
|
|
12432
12460
|
},
|
|
12433
12461
|
{ _id: false }
|
|
12434
12462
|
);
|
|
12435
|
-
var schemaDailyClueGameData = new
|
|
12463
|
+
var schemaDailyClueGameData = new MongooseSchema21(
|
|
12436
12464
|
{
|
|
12437
12465
|
gameFields: { required: true, type: schemaDailyClueBaseGame },
|
|
12438
12466
|
lastFoundDate: { default: null, required: false, type: Date },
|
|
@@ -12447,9 +12475,9 @@ var schemaDailyClueGameData = new MongooseSchema20(
|
|
|
12447
12475
|
);
|
|
12448
12476
|
|
|
12449
12477
|
// src/mongoose/game/MiniQuiz.ts
|
|
12450
|
-
import
|
|
12451
|
-
var
|
|
12452
|
-
var schemaMiniQuizAnswer = new
|
|
12478
|
+
import mongoose22 from "mongoose";
|
|
12479
|
+
var MongooseSchema22 = mongoose22.Schema;
|
|
12480
|
+
var schemaMiniQuizAnswer = new MongooseSchema22(
|
|
12453
12481
|
{
|
|
12454
12482
|
answer: { required: true, type: String },
|
|
12455
12483
|
answerId: { required: true, type: String },
|
|
@@ -12457,7 +12485,7 @@ var schemaMiniQuizAnswer = new MongooseSchema21(
|
|
|
12457
12485
|
},
|
|
12458
12486
|
{ _id: false }
|
|
12459
12487
|
);
|
|
12460
|
-
var schemaMiniQuizQuestion = new
|
|
12488
|
+
var schemaMiniQuizQuestion = new MongooseSchema22(
|
|
12461
12489
|
{
|
|
12462
12490
|
answers: { required: true, type: [schemaMiniQuizAnswer] },
|
|
12463
12491
|
question: { required: true, type: String },
|
|
@@ -12465,20 +12493,20 @@ var schemaMiniQuizQuestion = new MongooseSchema21(
|
|
|
12465
12493
|
},
|
|
12466
12494
|
{ _id: false }
|
|
12467
12495
|
);
|
|
12468
|
-
var schemaMiniQuizBaseGame = new
|
|
12496
|
+
var schemaMiniQuizBaseGame = new MongooseSchema22(
|
|
12469
12497
|
{
|
|
12470
12498
|
questions: { required: true, type: [schemaMiniQuizQuestion] }
|
|
12471
12499
|
},
|
|
12472
12500
|
{ _id: false }
|
|
12473
12501
|
);
|
|
12474
|
-
var schemaMiniQuizAnsweredQuestion = new
|
|
12502
|
+
var schemaMiniQuizAnsweredQuestion = new MongooseSchema22(
|
|
12475
12503
|
{
|
|
12476
12504
|
questionId: { required: true, type: String },
|
|
12477
12505
|
selectedAnswerId: { required: true, type: String }
|
|
12478
12506
|
},
|
|
12479
12507
|
{ _id: false }
|
|
12480
12508
|
);
|
|
12481
|
-
var schemaMiniQuizGameData = new
|
|
12509
|
+
var schemaMiniQuizGameData = new MongooseSchema22(
|
|
12482
12510
|
{
|
|
12483
12511
|
answeredQuestions: {
|
|
12484
12512
|
default: null,
|
|
@@ -12493,18 +12521,18 @@ var schemaMiniQuizGameData = new MongooseSchema21(
|
|
|
12493
12521
|
);
|
|
12494
12522
|
|
|
12495
12523
|
// src/mongoose/game/Game.ts
|
|
12496
|
-
var
|
|
12524
|
+
var MongooseSchema23 = mongoose23.Schema;
|
|
12497
12525
|
var gameDataSchemas = {
|
|
12498
12526
|
[EnumGameType.DAILY_CLUE]: schemaDailyClueGameData,
|
|
12499
12527
|
[EnumGameType.MINI_QUIZ]: schemaMiniQuizGameData
|
|
12500
12528
|
};
|
|
12501
12529
|
var gameDataDefinition = Object.fromEntries(
|
|
12502
|
-
Object.entries(gameDataSchemas).map(([key,
|
|
12530
|
+
Object.entries(gameDataSchemas).map(([key, schema17]) => [
|
|
12503
12531
|
key,
|
|
12504
|
-
{ default: null, required: false, type:
|
|
12532
|
+
{ default: null, required: false, type: schema17 }
|
|
12505
12533
|
])
|
|
12506
12534
|
);
|
|
12507
|
-
var gameHistorySchema = new
|
|
12535
|
+
var gameHistorySchema = new MongooseSchema23(
|
|
12508
12536
|
{
|
|
12509
12537
|
createdAt: { required: true, type: Date },
|
|
12510
12538
|
gameDate: { required: true, type: schemaGameDate },
|
|
@@ -12522,7 +12550,7 @@ var gameHistorySchema = new MongooseSchema22(
|
|
|
12522
12550
|
},
|
|
12523
12551
|
{ _id: false }
|
|
12524
12552
|
);
|
|
12525
|
-
var gameTypeSchema = new
|
|
12553
|
+
var gameTypeSchema = new MongooseSchema23(
|
|
12526
12554
|
{
|
|
12527
12555
|
active: { default: true, required: true, type: Boolean },
|
|
12528
12556
|
gameData: gameDataDefinition,
|
|
@@ -12536,7 +12564,7 @@ var gameTypeSchema = new MongooseSchema22(
|
|
|
12536
12564
|
},
|
|
12537
12565
|
{ timestamps: true }
|
|
12538
12566
|
);
|
|
12539
|
-
var
|
|
12567
|
+
var schema15 = new MongooseSchema23(
|
|
12540
12568
|
{
|
|
12541
12569
|
active: { default: false, required: true, type: Boolean },
|
|
12542
12570
|
deletedAt: { default: null, required: false, type: Date },
|
|
@@ -12549,12 +12577,12 @@ var schema14 = new MongooseSchema22(
|
|
|
12549
12577
|
},
|
|
12550
12578
|
{ timestamps: true }
|
|
12551
12579
|
);
|
|
12552
|
-
var GameModel =
|
|
12580
|
+
var GameModel = mongoose23.models.Game || mongoose23.model("Game", schema15);
|
|
12553
12581
|
|
|
12554
12582
|
// src/mongoose/School.ts
|
|
12555
|
-
import
|
|
12556
|
-
var
|
|
12557
|
-
var campaignsSchema = new
|
|
12583
|
+
import mongoose24 from "mongoose";
|
|
12584
|
+
var MongooseSchema24 = mongoose24.Schema;
|
|
12585
|
+
var campaignsSchema = new MongooseSchema24(
|
|
12558
12586
|
{
|
|
12559
12587
|
endDate: { required: true, type: Date },
|
|
12560
12588
|
name: { required: true, type: String },
|
|
@@ -12562,7 +12590,7 @@ var campaignsSchema = new MongooseSchema23(
|
|
|
12562
12590
|
},
|
|
12563
12591
|
{ _id: false }
|
|
12564
12592
|
);
|
|
12565
|
-
var
|
|
12593
|
+
var schema16 = new MongooseSchema24(
|
|
12566
12594
|
{
|
|
12567
12595
|
// New schools are active by default
|
|
12568
12596
|
active: { default: true, required: true, type: Boolean },
|
|
@@ -12588,10 +12616,10 @@ var schema15 = new MongooseSchema23(
|
|
|
12588
12616
|
},
|
|
12589
12617
|
{ timestamps: true }
|
|
12590
12618
|
);
|
|
12591
|
-
var SchoolModel =
|
|
12619
|
+
var SchoolModel = mongoose24.models.School || mongoose24.model("School", schema16);
|
|
12592
12620
|
|
|
12593
12621
|
// src/service/database.ts
|
|
12594
|
-
import
|
|
12622
|
+
import mongoose25 from "mongoose";
|
|
12595
12623
|
var connectToDatabase = async ({
|
|
12596
12624
|
appName,
|
|
12597
12625
|
dbName,
|
|
@@ -12604,7 +12632,7 @@ var connectToDatabase = async ({
|
|
|
12604
12632
|
// Fallback to MongoDB Atlas connection string
|
|
12605
12633
|
`mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
|
|
12606
12634
|
);
|
|
12607
|
-
await
|
|
12635
|
+
await mongoose25.connect(mongoUri);
|
|
12608
12636
|
const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
|
|
12609
12637
|
console.log(
|
|
12610
12638
|
`${connectionType} connected from server/src/service/database.ts`
|
|
@@ -12783,84 +12811,102 @@ async function updateAdStatuses() {
|
|
|
12783
12811
|
}
|
|
12784
12812
|
|
|
12785
12813
|
// src/service/associate.ts
|
|
12786
|
-
import
|
|
12787
|
-
|
|
12788
|
-
|
|
12789
|
-
|
|
12814
|
+
import mongoose26 from "mongoose";
|
|
12815
|
+
function normalizeObjectId(id) {
|
|
12816
|
+
return typeof id === "string" ? new mongoose26.Types.ObjectId(id) : id;
|
|
12817
|
+
}
|
|
12818
|
+
async function getAssociateEmailsForResource({
|
|
12819
|
+
normalizedResourceId,
|
|
12790
12820
|
resourceType
|
|
12791
12821
|
}) {
|
|
12792
|
-
|
|
12793
|
-
|
|
12794
|
-
|
|
12795
|
-
|
|
12796
|
-
|
|
12797
|
-
|
|
12798
|
-
$elemMatch: {
|
|
12799
|
-
resourceId: normalizedResourceId,
|
|
12800
|
-
resourceType
|
|
12801
|
-
}
|
|
12822
|
+
const usersWithAssociates = await UserModel.find(
|
|
12823
|
+
{
|
|
12824
|
+
associates: {
|
|
12825
|
+
$elemMatch: {
|
|
12826
|
+
resourceId: normalizedResourceId,
|
|
12827
|
+
resourceType
|
|
12802
12828
|
}
|
|
12803
|
-
}
|
|
12804
|
-
|
|
12805
|
-
|
|
12806
|
-
|
|
12807
|
-
|
|
12808
|
-
|
|
12809
|
-
|
|
12810
|
-
|
|
12811
|
-
|
|
12812
|
-
|
|
12813
|
-
|
|
12814
|
-
)
|
|
12829
|
+
}
|
|
12830
|
+
},
|
|
12831
|
+
{
|
|
12832
|
+
associates: 1
|
|
12833
|
+
}
|
|
12834
|
+
).lean();
|
|
12835
|
+
return [
|
|
12836
|
+
...new Set(
|
|
12837
|
+
usersWithAssociates.flatMap(
|
|
12838
|
+
(user) => (user.associates ?? []).filter(
|
|
12839
|
+
(associate) => associate.resourceId === normalizedResourceId && associate.resourceType === resourceType
|
|
12840
|
+
).map((associate) => associate.email)
|
|
12815
12841
|
)
|
|
12816
|
-
|
|
12817
|
-
|
|
12818
|
-
|
|
12819
|
-
|
|
12820
|
-
|
|
12821
|
-
|
|
12842
|
+
)
|
|
12843
|
+
];
|
|
12844
|
+
}
|
|
12845
|
+
async function pullAssociatesFromUsers({
|
|
12846
|
+
normalizedResourceId,
|
|
12847
|
+
resourceType
|
|
12848
|
+
}) {
|
|
12849
|
+
await UserModel.updateMany(
|
|
12850
|
+
{
|
|
12851
|
+
associates: {
|
|
12852
|
+
$elemMatch: {
|
|
12853
|
+
resourceId: normalizedResourceId,
|
|
12854
|
+
resourceType
|
|
12855
|
+
}
|
|
12856
|
+
}
|
|
12857
|
+
},
|
|
12858
|
+
{
|
|
12859
|
+
$pull: {
|
|
12822
12860
|
associates: {
|
|
12823
|
-
|
|
12824
|
-
|
|
12825
|
-
resourceType
|
|
12826
|
-
}
|
|
12861
|
+
resourceId: normalizedResourceId,
|
|
12862
|
+
resourceType
|
|
12827
12863
|
}
|
|
12828
|
-
}
|
|
12829
|
-
|
|
12830
|
-
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
|
|
12834
|
-
|
|
12864
|
+
}
|
|
12865
|
+
}
|
|
12866
|
+
);
|
|
12867
|
+
}
|
|
12868
|
+
async function pullAssociateParticipantsFromChats(resourceOwnerId, associateEmails) {
|
|
12869
|
+
await ChatModel.updateMany(
|
|
12870
|
+
{
|
|
12871
|
+
active: true,
|
|
12872
|
+
chatType: EnumChatType.RELATION,
|
|
12873
|
+
deletedAt: null,
|
|
12874
|
+
participants: {
|
|
12875
|
+
$elemMatch: {
|
|
12876
|
+
userId: resourceOwnerId
|
|
12835
12877
|
}
|
|
12836
12878
|
}
|
|
12837
|
-
|
|
12838
|
-
|
|
12839
|
-
{
|
|
12840
|
-
active: true,
|
|
12841
|
-
chatType: EnumChatType.RELATION,
|
|
12842
|
-
deletedAt: null,
|
|
12879
|
+
},
|
|
12880
|
+
{
|
|
12881
|
+
$pull: {
|
|
12843
12882
|
participants: {
|
|
12844
|
-
|
|
12845
|
-
|
|
12883
|
+
isAssociate: true,
|
|
12884
|
+
userEmail: {
|
|
12885
|
+
$in: associateEmails
|
|
12846
12886
|
}
|
|
12847
12887
|
}
|
|
12848
|
-
},
|
|
12849
|
-
{
|
|
12850
|
-
$set: {
|
|
12851
|
-
"participants.$[associate].active": false
|
|
12852
|
-
}
|
|
12853
|
-
},
|
|
12854
|
-
{
|
|
12855
|
-
arrayFilters: [
|
|
12856
|
-
{
|
|
12857
|
-
"associate.isAssociate": true,
|
|
12858
|
-
"associate.userEmail": {
|
|
12859
|
-
$in: associateEmails
|
|
12860
|
-
}
|
|
12861
|
-
}
|
|
12862
|
-
]
|
|
12863
12888
|
}
|
|
12889
|
+
}
|
|
12890
|
+
);
|
|
12891
|
+
}
|
|
12892
|
+
async function removeAssociateFromResource({
|
|
12893
|
+
resourceId,
|
|
12894
|
+
resourceOwnerId,
|
|
12895
|
+
resourceType
|
|
12896
|
+
}) {
|
|
12897
|
+
try {
|
|
12898
|
+
const scope = {
|
|
12899
|
+
normalizedResourceId: resourceId.toString(),
|
|
12900
|
+
resourceType
|
|
12901
|
+
};
|
|
12902
|
+
const associateEmails = await getAssociateEmailsForResource(scope);
|
|
12903
|
+
if (associateEmails.length === 0) {
|
|
12904
|
+
return;
|
|
12905
|
+
}
|
|
12906
|
+
await pullAssociatesFromUsers(scope);
|
|
12907
|
+
await pullAssociateParticipantsFromChats(
|
|
12908
|
+
normalizeObjectId(resourceOwnerId),
|
|
12909
|
+
associateEmails
|
|
12864
12910
|
);
|
|
12865
12911
|
} catch (error) {
|
|
12866
12912
|
console.error(
|
|
@@ -12919,12 +12965,12 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
|
|
|
12919
12965
|
}
|
|
12920
12966
|
|
|
12921
12967
|
// src/service/objectIdToString.ts
|
|
12922
|
-
import
|
|
12968
|
+
import mongoose27 from "mongoose";
|
|
12923
12969
|
function convertObjectIdsToStrings(obj) {
|
|
12924
12970
|
if (obj === null || obj === void 0) {
|
|
12925
12971
|
return obj;
|
|
12926
12972
|
}
|
|
12927
|
-
if (obj instanceof
|
|
12973
|
+
if (obj instanceof mongoose27.Types.ObjectId) {
|
|
12928
12974
|
return obj.toString();
|
|
12929
12975
|
}
|
|
12930
12976
|
if (Array.isArray(obj)) {
|
|
@@ -12968,7 +13014,7 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
12968
13014
|
|
|
12969
13015
|
// src/types/index.ts
|
|
12970
13016
|
import express from "express";
|
|
12971
|
-
import
|
|
13017
|
+
import mongoose28 from "mongoose";
|
|
12972
13018
|
var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
|
|
12973
13019
|
EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
|
|
12974
13020
|
EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
|
|
@@ -13001,6 +13047,7 @@ export {
|
|
|
13001
13047
|
SchoolModel,
|
|
13002
13048
|
SocialMediaTypeSchema,
|
|
13003
13049
|
StallTypeSchema,
|
|
13050
|
+
UnregisteredVendorModel,
|
|
13004
13051
|
UserModel,
|
|
13005
13052
|
VendorInfoModel,
|
|
13006
13053
|
VendorModel,
|
|
@@ -13014,7 +13061,7 @@ export {
|
|
|
13014
13061
|
findEventOrImportedMarketById,
|
|
13015
13062
|
locationGeoSchema,
|
|
13016
13063
|
locationsSchema,
|
|
13017
|
-
|
|
13064
|
+
mongoose28 as mongoose,
|
|
13018
13065
|
refundPolicySchema,
|
|
13019
13066
|
relationDatesSchema,
|
|
13020
13067
|
resourceRelationsSchema,
|