@memberjunction/generic-database-provider 6.2.0-edge.5 → 6.2.0-edge.7
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/README.md +165 -1
- package/dist/GenericDatabaseProvider.d.ts +599 -69
- package/dist/GenericDatabaseProvider.d.ts.map +1 -1
- package/dist/GenericDatabaseProvider.js +2055 -403
- package/dist/GenericDatabaseProvider.js.map +1 -1
- package/dist/SqlLogger.d.ts +26 -0
- package/dist/SqlLogger.d.ts.map +1 -1
- package/dist/SqlLogger.js +77 -20
- package/dist/SqlLogger.js.map +1 -1
- package/dist/clientClauseScreen.d.ts +44 -75
- package/dist/clientClauseScreen.d.ts.map +1 -1
- package/dist/clientClauseScreen.js +129 -267
- package/dist/clientClauseScreen.js.map +1 -1
- package/dist/composition/compositionAssembler.d.ts +33 -0
- package/dist/composition/compositionAssembler.d.ts.map +1 -0
- package/dist/composition/compositionAssembler.js +270 -0
- package/dist/composition/compositionAssembler.js.map +1 -0
- package/dist/composition/compositionInfo.d.ts +7 -0
- package/dist/composition/compositionInfo.d.ts.map +1 -0
- package/dist/composition/compositionInfo.js +31 -0
- package/dist/composition/compositionInfo.js.map +1 -0
- package/dist/composition/compositionLookup.d.ts +44 -0
- package/dist/composition/compositionLookup.d.ts.map +1 -0
- package/dist/composition/compositionLookup.js +122 -0
- package/dist/composition/compositionLookup.js.map +1 -0
- package/dist/composition/compositionRender.d.ts +136 -0
- package/dist/composition/compositionRender.d.ts.map +1 -0
- package/dist/composition/compositionRender.js +264 -0
- package/dist/composition/compositionRender.js.map +1 -0
- package/dist/composition/compositionTypes.d.ts +40 -0
- package/dist/composition/compositionTypes.d.ts.map +1 -0
- package/dist/composition/compositionTypes.js +2 -0
- package/dist/composition/compositionTypes.js.map +1 -0
- package/dist/composition/quotedTagRefusal.d.ts +44 -0
- package/dist/composition/quotedTagRefusal.d.ts.map +1 -0
- package/dist/composition/quotedTagRefusal.js +132 -0
- package/dist/composition/quotedTagRefusal.js.map +1 -0
- package/dist/composition/renderSteps.d.ts +16 -0
- package/dist/composition/renderSteps.d.ts.map +1 -0
- package/dist/composition/renderSteps.js +42 -0
- package/dist/composition/renderSteps.js.map +1 -0
- package/dist/composition/safetyGate.d.ts +46 -0
- package/dist/composition/safetyGate.d.ts.map +1 -0
- package/dist/composition/safetyGate.js +61 -0
- package/dist/composition/safetyGate.js.map +1 -0
- package/dist/composition/templateUnit.d.ts +95 -0
- package/dist/composition/templateUnit.d.ts.map +1 -0
- package/dist/composition/templateUnit.js +189 -0
- package/dist/composition/templateUnit.js.map +1 -0
- package/dist/describeStatement.d.ts +51 -0
- package/dist/describeStatement.d.ts.map +1 -0
- package/dist/describeStatement.js +19 -0
- package/dist/describeStatement.js.map +1 -0
- package/dist/fieldSecurity/projectionStars.d.ts +15 -0
- package/dist/fieldSecurity/projectionStars.d.ts.map +1 -0
- package/dist/fieldSecurity/projectionStars.js +116 -0
- package/dist/fieldSecurity/projectionStars.js.map +1 -0
- package/dist/fieldSecurity/queryColumnSecurity.d.ts +35 -0
- package/dist/fieldSecurity/queryColumnSecurity.d.ts.map +1 -0
- package/dist/fieldSecurity/queryColumnSecurity.js +84 -0
- package/dist/fieldSecurity/queryColumnSecurity.js.map +1 -0
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/pagingLayout.d.ts +68 -0
- package/dist/pagingLayout.d.ts.map +1 -0
- package/dist/pagingLayout.js +190 -0
- package/dist/pagingLayout.js.map +1 -0
- package/dist/queryCompositionEngine.d.ts +22 -222
- package/dist/queryCompositionEngine.d.ts.map +1 -1
- package/dist/queryCompositionEngine.js +35 -729
- package/dist/queryCompositionEngine.js.map +1 -1
- package/dist/queryPagingEngine.d.ts +26 -5
- package/dist/queryPagingEngine.d.ts.map +1 -1
- package/dist/queryPagingEngine.js +51 -15
- package/dist/queryPagingEngine.js.map +1 -1
- package/dist/recordChangeSnapshot.d.ts +43 -0
- package/dist/recordChangeSnapshot.d.ts.map +1 -0
- package/dist/recordChangeSnapshot.js +85 -0
- package/dist/recordChangeSnapshot.js.map +1 -0
- package/dist/renderPipeline.d.ts +91 -72
- package/dist/renderPipeline.d.ts.map +1 -1
- package/dist/renderPipeline.js +71 -179
- package/dist/renderPipeline.js.map +1 -1
- package/dist/statementMemo.d.ts +29 -0
- package/dist/statementMemo.d.ts.map +1 -0
- package/dist/statementMemo.js +61 -0
- package/dist/statementMemo.js.map +1 -0
- package/dist/systemUserFieldAccess.d.ts +16 -1
- package/dist/systemUserFieldAccess.d.ts.map +1 -1
- package/dist/systemUserFieldAccess.js +39 -8
- package/dist/systemUserFieldAccess.js.map +1 -1
- package/dist/typedQueryParameter.d.ts +55 -0
- package/dist/typedQueryParameter.d.ts.map +1 -0
- package/dist/typedQueryParameter.js +122 -0
- package/dist/typedQueryParameter.js.map +1 -0
- package/dist/types.d.ts +47 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +14 -14
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
/**
|
|
3
|
+
* A bounded memo of facts about SQL statements, keyed by a SHA-256 of the dialect key and the
|
|
4
|
+
* statement text, so a long statement is never kept as a key. When full, the entry stored longest
|
|
5
|
+
* ago goes first. An optional lifetime makes an entry expire, for facts that depend on the
|
|
6
|
+
* database schema rather than on the text alone.
|
|
7
|
+
*/
|
|
8
|
+
export class StatementMemo {
|
|
9
|
+
/**
|
|
10
|
+
* @param maxEntries - How many entries are kept.
|
|
11
|
+
* @param ttlMs - How long an entry is trusted, in milliseconds; `null` for as long as it is kept.
|
|
12
|
+
*/
|
|
13
|
+
constructor(maxEntries, ttlMs = null) {
|
|
14
|
+
this.maxEntries = maxEntries;
|
|
15
|
+
this.ttlMs = ttlMs;
|
|
16
|
+
this.entries = new Map();
|
|
17
|
+
}
|
|
18
|
+
/** The key of `sql` read in `dialectKey`. */
|
|
19
|
+
static KeyOf(sql, dialectKey) {
|
|
20
|
+
return createHash('sha256').update(dialectKey).update('\u0000').update(sql).digest('hex');
|
|
21
|
+
}
|
|
22
|
+
/** The value kept under `key`; undefined when there is none or it has expired. */
|
|
23
|
+
Get(key, now = Date.now()) {
|
|
24
|
+
const entry = this.entries.get(key);
|
|
25
|
+
if (!entry)
|
|
26
|
+
return undefined;
|
|
27
|
+
if (this.ttlMs !== null && now - entry.At > this.ttlMs) {
|
|
28
|
+
this.entries.delete(key);
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
return entry.Value;
|
|
32
|
+
}
|
|
33
|
+
/** Keeps `value` under `key`, dropping the oldest entry when full. */
|
|
34
|
+
Set(key, value, now = Date.now()) {
|
|
35
|
+
this.entries.delete(key);
|
|
36
|
+
if (this.entries.size >= this.maxEntries) {
|
|
37
|
+
const oldest = this.entries.keys().next();
|
|
38
|
+
if (!oldest.done)
|
|
39
|
+
this.entries.delete(oldest.value);
|
|
40
|
+
}
|
|
41
|
+
this.entries.set(key, { Value: value, At: now });
|
|
42
|
+
}
|
|
43
|
+
/** The value under `key`, computing and keeping it on a miss. */
|
|
44
|
+
GetOrCompute(key, compute) {
|
|
45
|
+
const kept = this.Get(key);
|
|
46
|
+
if (kept !== undefined)
|
|
47
|
+
return kept;
|
|
48
|
+
const value = compute();
|
|
49
|
+
this.Set(key, value);
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
/** Forgets the entry under `key`. */
|
|
53
|
+
Delete(key) {
|
|
54
|
+
this.entries.delete(key);
|
|
55
|
+
}
|
|
56
|
+
/** How many entries are kept. */
|
|
57
|
+
get Size() {
|
|
58
|
+
return this.entries.size;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=statementMemo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statementMemo.js","sourceRoot":"","sources":["../src/statementMemo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU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CAAC,IAAI,EAAE,CAAC;YAC1C,IAAI,CAAC,MAAM,CAAC,IAAI;gBAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACxD,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,iEAAiE;IACjE,YAAY,CAAC,GAAW,EAAE,OAAgB;QACtC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC3B,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC;QACpC,MAAM,KAAK,GAAG,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACrB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,qCAAqC;IACrC,MAAM,CAAC,GAAW;QACd,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,iCAAiC;IACjC,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC7B,CAAC;CACJ"}
|
|
@@ -72,8 +72,10 @@ export type SystemUserFieldAccessViolation = {
|
|
|
72
72
|
* @param entity the entity the field belongs to
|
|
73
73
|
* @param field the field whose rules are changing
|
|
74
74
|
* @param projectedRules every rule that would bind to this field after the change
|
|
75
|
+
* @param systemUser the account to check, for callers that read its role set from the database;
|
|
76
|
+
* defaults to the user cache's system user
|
|
75
77
|
*/
|
|
76
|
-
export declare function SystemUserFieldAccessLossReason(entity: EntityInfo | null | undefined, field: EntityFieldInfo | null | undefined, projectedRules: readonly FieldPermissionRuleForRole[]): string | null;
|
|
78
|
+
export declare function SystemUserFieldAccessLossReason(entity: EntityInfo | null | undefined, field: EntityFieldInfo | null | undefined, projectedRules: readonly FieldPermissionRuleForRole[], systemUser?: UserInfo | null): string | null;
|
|
77
79
|
/** Narrowing for {@link FindSystemUserFieldAccessViolations}. */
|
|
78
80
|
export type SystemUserFieldAccessSweepOptions = {
|
|
79
81
|
/**
|
|
@@ -86,6 +88,13 @@ export type SystemUserFieldAccessSweepOptions = {
|
|
|
86
88
|
* up, and field rules decide nothing.
|
|
87
89
|
*/
|
|
88
90
|
WithoutRoleID?: string;
|
|
91
|
+
/**
|
|
92
|
+
* The rules to judge each field by, keyed by lower-case `EntityFieldID`, in place of the rules
|
|
93
|
+
* on loaded metadata. For callers that read the rules from the database because loaded
|
|
94
|
+
* metadata may lag a write made a moment ago. A field absent from the map has no rule for any
|
|
95
|
+
* role the system user holds, so only rules bound to those roles need to be in it.
|
|
96
|
+
*/
|
|
97
|
+
RulesByFieldID?: ReadonlyMap<string, readonly FieldPermissionRuleForRole[]>;
|
|
89
98
|
};
|
|
90
99
|
/**
|
|
91
100
|
* Every field on an FLS-enabled entity that the system user cannot fully use.
|
|
@@ -94,6 +103,12 @@ export type SystemUserFieldAccessSweepOptions = {
|
|
|
94
103
|
* while the user cache was cold. Walks loaded metadata only — no queries — and skips entities with
|
|
95
104
|
* field security switched off, which is nearly all of them.
|
|
96
105
|
*
|
|
106
|
+
* With `WithoutRoleID` (the role-removal guard) an entity with field security switched off is
|
|
107
|
+
* judged too, on the fields that carry rules: those rules are dormant, not gone, and apply again
|
|
108
|
+
* the moment field security is re-enabled, so skipping them would let "disable, remove the role,
|
|
109
|
+
* re-enable" strip the system user's access with no refusal anywhere. Such a field is reported
|
|
110
|
+
* only when the removal itself costs the access, never for a shortfall that already existed.
|
|
111
|
+
*
|
|
97
112
|
* @param provider the provider whose metadata to walk
|
|
98
113
|
* @param systemUser the account to check; defaults to the user cache's system user
|
|
99
114
|
* @param options optional projection — see {@link SystemUserFieldAccessSweepOptions}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemUserFieldAccess.d.ts","sourceRoot":"","sources":["../src/systemUserFieldAccess.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EACH,eAAe,EACf,UAAU,EACV,0BAA0B,EAC1B,iBAAiB,EACjB,QAAQ,EACX,MAAM,sBAAsB,CAAC;AAI9B;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;CACtC,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"systemUserFieldAccess.d.ts","sourceRoot":"","sources":["../src/systemUserFieldAccess.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EACH,eAAe,EACf,UAAU,EACV,0BAA0B,EAC1B,iBAAiB,EACjB,QAAQ,EACX,MAAM,sBAAsB,CAAC;AAI9B;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;CACtC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,+BAA+B,CAC3C,MAAM,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EACrC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,EACzC,cAAc,EAAE,SAAS,0BAA0B,EAAE,EACrD,UAAU,CAAC,EAAE,QAAQ,GAAG,IAAI,GAC7B,MAAM,GAAG,IAAI,CAwBf;AAED,iEAAiE;AACjE,MAAM,MAAM,iCAAiC,GAAG;IAC5C;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,0BAA0B,EAAE,CAAC,CAAC;CAC/E,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mCAAmC,CAC/C,QAAQ,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,EAC9C,UAAU,CAAC,EAAE,QAAQ,GAAG,IAAI,EAC5B,OAAO,GAAE,iCAAsC,GAChD,8BAA8B,EAAE,CAqBlC;AA4ED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAM9E"}
|
|
@@ -65,12 +65,14 @@ import { UserCache } from './UserCache.js';
|
|
|
65
65
|
* @param entity the entity the field belongs to
|
|
66
66
|
* @param field the field whose rules are changing
|
|
67
67
|
* @param projectedRules every rule that would bind to this field after the change
|
|
68
|
+
* @param systemUser the account to check, for callers that read its role set from the database;
|
|
69
|
+
* defaults to the user cache's system user
|
|
68
70
|
*/
|
|
69
|
-
export function SystemUserFieldAccessLossReason(entity, field, projectedRules) {
|
|
71
|
+
export function SystemUserFieldAccessLossReason(entity, field, projectedRules, systemUser) {
|
|
70
72
|
if (!entity || !field) {
|
|
71
73
|
return null;
|
|
72
74
|
}
|
|
73
|
-
|
|
75
|
+
systemUser = systemUser ?? resolveSystemUser();
|
|
74
76
|
if (!systemUser) {
|
|
75
77
|
return null;
|
|
76
78
|
}
|
|
@@ -95,6 +97,12 @@ export function SystemUserFieldAccessLossReason(entity, field, projectedRules) {
|
|
|
95
97
|
* while the user cache was cold. Walks loaded metadata only — no queries — and skips entities with
|
|
96
98
|
* field security switched off, which is nearly all of them.
|
|
97
99
|
*
|
|
100
|
+
* With `WithoutRoleID` (the role-removal guard) an entity with field security switched off is
|
|
101
|
+
* judged too, on the fields that carry rules: those rules are dormant, not gone, and apply again
|
|
102
|
+
* the moment field security is re-enabled, so skipping them would let "disable, remove the role,
|
|
103
|
+
* re-enable" strip the system user's access with no refusal anywhere. Such a field is reported
|
|
104
|
+
* only when the removal itself costs the access, never for a shortfall that already existed.
|
|
105
|
+
*
|
|
98
106
|
* @param provider the provider whose metadata to walk
|
|
99
107
|
* @param systemUser the account to check; defaults to the user cache's system user
|
|
100
108
|
* @param options optional projection — see {@link SystemUserFieldAccessSweepOptions}
|
|
@@ -107,14 +115,12 @@ export function FindSystemUserFieldAccessViolations(provider, systemUser, option
|
|
|
107
115
|
const user = options.WithoutRoleID ? projectUserWithoutRole(resolved, options.WithoutRoleID) : resolved;
|
|
108
116
|
const violations = [];
|
|
109
117
|
for (const entity of provider.Entities ?? []) {
|
|
110
|
-
|
|
111
|
-
|
|
118
|
+
const dormant = !entity.EnableFieldLevelSecurity;
|
|
119
|
+
if (dormant && !options.WithoutRoleID) {
|
|
120
|
+
continue; // dormant rules restrict nothing until field security is re-enabled
|
|
112
121
|
}
|
|
113
122
|
for (const field of entity.Fields) {
|
|
114
|
-
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
const lost = lostVerb(entity, field, field.FieldPermissions, user);
|
|
123
|
+
const lost = fieldViolation(entity, field, rulesForField(field, options), user, dormant ? resolved : null);
|
|
118
124
|
if (lost) {
|
|
119
125
|
violations.push({ EntityName: entity.Name, FieldName: field.Name, Verb: lost });
|
|
120
126
|
}
|
|
@@ -122,6 +128,31 @@ export function FindSystemUserFieldAccessViolations(provider, systemUser, option
|
|
|
122
128
|
}
|
|
123
129
|
return violations;
|
|
124
130
|
}
|
|
131
|
+
/** The rules to judge a field by: the caller's stored rules when supplied, else loaded metadata. */
|
|
132
|
+
function rulesForField(field, options) {
|
|
133
|
+
if (!options.RulesByFieldID) {
|
|
134
|
+
return field.FieldPermissions;
|
|
135
|
+
}
|
|
136
|
+
return options.RulesByFieldID.get(String(field.ID ?? '').trim().toLowerCase()) ?? [];
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The verb `user` lacks on one field, or null. For a dormant field (`before` is the user as it is
|
|
140
|
+
* now, before the change being judged) only a field with rules counts, and only when `before`
|
|
141
|
+
* still has that verb, so the change is what costs it.
|
|
142
|
+
*/
|
|
143
|
+
function fieldViolation(entity, field, rules, user, before) {
|
|
144
|
+
if (field.IsUnrestrictableField || field.IsOnUnrestrictableEntity) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
if (before && rules.length === 0) {
|
|
148
|
+
return null; // no dormant rule: re-enabling seeds this field afresh
|
|
149
|
+
}
|
|
150
|
+
const lost = lostVerb(entity, field, rules, user);
|
|
151
|
+
if (!lost || (before && lostVerb(entity, field, rules, before))) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
return lost;
|
|
155
|
+
}
|
|
125
156
|
/**
|
|
126
157
|
* Which verb the system user would lose relative to its ENTITY-level access, or null.
|
|
127
158
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemUserFieldAccess.js","sourceRoot":"","sources":["../src/systemUserFieldAccess.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EACH,eAAe,EAIf,QAAQ,GACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAY3C
|
|
1
|
+
{"version":3,"file":"systemUserFieldAccess.js","sourceRoot":"","sources":["../src/systemUserFieldAccess.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EACH,eAAe,EAIf,QAAQ,GACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAY3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,U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mB,CAAC,MAAiC;IACjE,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,UAAU,GAAG,iBAAiB,EAAE,CAAC;IACvC,OAAO,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,sBAAsB,CAAC,IAAc,EAAE,MAAc;IAC1D,6FAA6F;IAC7F,6CAA6C;IAC7C,OAAO,IAAI,QAAQ,CAAC,SAAS,EAAE;QAC3B,GAAG,IAAI;QACP,SAAS,EAAE,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACjF,CAAC,CAAC;AACP,CAAC;AAED,qEAAqE;AACrE,SAAS,iBAAiB;IACtB,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,EAAE,aAAa,EAAE,EAAE,CAAC;IACnD,OAAO,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** A value a {@link TypedQueryParameter} carries. */
|
|
2
|
+
export type TypedQueryParameterValue = string | number | boolean | Date | null;
|
|
3
|
+
/**
|
|
4
|
+
* One bind parameter with the database type of the column it is compared with, such as
|
|
5
|
+
* `varchar(50)` or `datetime2(7)`. Statements reference it by the placeholder the dialect's
|
|
6
|
+
* binding gives (`DialectBinding.TypedParameter`): SQL Server providers bind it by name with that
|
|
7
|
+
* declared type, so a varchar column is compared with a varchar value and keeps its index seek;
|
|
8
|
+
* PostgreSQL providers bind it by position, and the placeholder casts it.
|
|
9
|
+
*/
|
|
10
|
+
export declare class TypedQueryParameter {
|
|
11
|
+
/** The name the driver binds it under (`mj_p0`), or its position's name (`$1`). */
|
|
12
|
+
readonly Name: string;
|
|
13
|
+
/** The database type, as the server describes it. */
|
|
14
|
+
readonly SQLType: string;
|
|
15
|
+
readonly Value: TypedQueryParameterValue;
|
|
16
|
+
constructor(
|
|
17
|
+
/** The name the driver binds it under (`mj_p0`), or its position's name (`$1`). */
|
|
18
|
+
Name: string,
|
|
19
|
+
/** The database type, as the server describes it. */
|
|
20
|
+
SQLType: string, Value: TypedQueryParameterValue);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* One bind parameter passed by name, whose type the driver infers from the value. Statements
|
|
24
|
+
* reference it by the dialect's placeholder (`DialectBinding.ParameterPlaceholder`): SQL Server
|
|
25
|
+
* providers bind it by name (`@p0` is bound as `p0`) and leave the statement text alone; PostgreSQL
|
|
26
|
+
* providers bind it by position (`$1`).
|
|
27
|
+
*
|
|
28
|
+
* This is how MJ's own parameterized SQL passes untyped values. A plain array of values is the
|
|
29
|
+
* legacy positional form, which SQL Server providers bind by rewriting every `?` in the text,
|
|
30
|
+
* including a `?` inside a string literal, quoted identifier or comment.
|
|
31
|
+
*/
|
|
32
|
+
export declare class NamedQueryParameter {
|
|
33
|
+
/** The name the driver binds it under (`p0`), or its position's name (`$1`). */
|
|
34
|
+
readonly Name: string;
|
|
35
|
+
readonly Value: TypedQueryParameterValue;
|
|
36
|
+
constructor(
|
|
37
|
+
/** The name the driver binds it under (`p0`), or its position's name (`$1`). */
|
|
38
|
+
Name: string, Value: TypedQueryParameterValue);
|
|
39
|
+
}
|
|
40
|
+
/** True when `parameters` is a non-empty list of {@link NamedQueryParameter}. */
|
|
41
|
+
export declare function IsNamedQueryParameterList(parameters: unknown): parameters is NamedQueryParameter[];
|
|
42
|
+
/** True when `parameters` is a non-empty list of {@link TypedQueryParameter}. */
|
|
43
|
+
export declare function IsTypedQueryParameterList(parameters: unknown): parameters is TypedQueryParameter[];
|
|
44
|
+
/**
|
|
45
|
+
* `value` converted to what a parameter of database type `sqlType` binds: a boolean for a bit or
|
|
46
|
+
* boolean column, a finite number for a numeric one, a `Date` for a date or timestamp one, and text
|
|
47
|
+
* otherwise. Undefined when the value cannot be one (a non-numeric string for an int column, an
|
|
48
|
+
* invalid date), so the caller can refuse rather than bind a value the database would reject or
|
|
49
|
+
* read differently.
|
|
50
|
+
*
|
|
51
|
+
* @param value - The value, in native form (booleans as booleans, dates as `Date` or ISO text with its zone).
|
|
52
|
+
* @param sqlType - The column's type as the server describes it, such as `varchar(50)` or `timestamp with time zone`.
|
|
53
|
+
*/
|
|
54
|
+
export declare function TypedBindValue(value: unknown, sqlType: string): TypedQueryParameterValue | undefined;
|
|
55
|
+
//# sourceMappingURL=typedQueryParameter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typedQueryParameter.d.ts","sourceRoot":"","sources":["../src/typedQueryParameter.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,MAAM,MAAM,wBAAwB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC;AAE/E;;;;;;GAMG;AACH,qBAAa,mBAAmB;IAExB,mFAAmF;aACnE,IAAI,EAAE,MAAM;IAC5B,qDAAqD;aACrC,OAAO,EAAE,MAAM;aACf,KAAK,EAAE,wBAAwB;;IAJ/C,mFAAmF;IACnE,IAAI,EAAE,MAAM;IAC5B,qDAAqD;IACrC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,wBAAwB;CAEtD;AAED;;;;;;;;;GASG;AACH,qBAAa,mBAAmB;IAExB,gFAAgF;aAChE,IAAI,EAAE,MAAM;aACZ,KAAK,EAAE,wBAAwB;;IAF/C,gFAAgF;IAChE,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,wBAAwB;CAEtD;AAED,iFAAiF;AACjF,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,IAAI,mBAAmB,EAAE,CAElG;AAED,iFAAiF;AACjF,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,IAAI,mBAAmB,EAAE,CAElG;AAcD;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,wBAAwB,GAAG,SAAS,CAYpG"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One bind parameter with the database type of the column it is compared with, such as
|
|
3
|
+
* `varchar(50)` or `datetime2(7)`. Statements reference it by the placeholder the dialect's
|
|
4
|
+
* binding gives (`DialectBinding.TypedParameter`): SQL Server providers bind it by name with that
|
|
5
|
+
* declared type, so a varchar column is compared with a varchar value and keeps its index seek;
|
|
6
|
+
* PostgreSQL providers bind it by position, and the placeholder casts it.
|
|
7
|
+
*/
|
|
8
|
+
export class TypedQueryParameter {
|
|
9
|
+
constructor(
|
|
10
|
+
/** The name the driver binds it under (`mj_p0`), or its position's name (`$1`). */
|
|
11
|
+
Name,
|
|
12
|
+
/** The database type, as the server describes it. */
|
|
13
|
+
SQLType, Value) {
|
|
14
|
+
this.Name = Name;
|
|
15
|
+
this.SQLType = SQLType;
|
|
16
|
+
this.Value = Value;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* One bind parameter passed by name, whose type the driver infers from the value. Statements
|
|
21
|
+
* reference it by the dialect's placeholder (`DialectBinding.ParameterPlaceholder`): SQL Server
|
|
22
|
+
* providers bind it by name (`@p0` is bound as `p0`) and leave the statement text alone; PostgreSQL
|
|
23
|
+
* providers bind it by position (`$1`).
|
|
24
|
+
*
|
|
25
|
+
* This is how MJ's own parameterized SQL passes untyped values. A plain array of values is the
|
|
26
|
+
* legacy positional form, which SQL Server providers bind by rewriting every `?` in the text,
|
|
27
|
+
* including a `?` inside a string literal, quoted identifier or comment.
|
|
28
|
+
*/
|
|
29
|
+
export class NamedQueryParameter {
|
|
30
|
+
constructor(
|
|
31
|
+
/** The name the driver binds it under (`p0`), or its position's name (`$1`). */
|
|
32
|
+
Name, Value) {
|
|
33
|
+
this.Name = Name;
|
|
34
|
+
this.Value = Value;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** True when `parameters` is a non-empty list of {@link NamedQueryParameter}. */
|
|
38
|
+
export function IsNamedQueryParameterList(parameters) {
|
|
39
|
+
return Array.isArray(parameters) && parameters.length > 0 && parameters.every(p => p instanceof NamedQueryParameter);
|
|
40
|
+
}
|
|
41
|
+
/** True when `parameters` is a non-empty list of {@link TypedQueryParameter}. */
|
|
42
|
+
export function IsTypedQueryParameterList(parameters) {
|
|
43
|
+
return Array.isArray(parameters) && parameters.length > 0 && parameters.every(p => p instanceof TypedQueryParameter);
|
|
44
|
+
}
|
|
45
|
+
/** Base types (lower case, without arguments) whose values bind as booleans. */
|
|
46
|
+
const BOOLEAN_TYPES = new Set(['bit', 'boolean', 'bool']);
|
|
47
|
+
/** Base types whose values bind as numbers. */
|
|
48
|
+
const NUMERIC_TYPES = new Set([
|
|
49
|
+
'int', 'integer', 'bigint', 'smallint', 'tinyint', 'decimal', 'numeric', 'float', 'real', 'money', 'smallmoney',
|
|
50
|
+
'double precision', 'int2', 'int4', 'int8', 'float4', 'float8',
|
|
51
|
+
]);
|
|
52
|
+
/** Base types whose values bind as dates (`timestamp…` forms included). */
|
|
53
|
+
const DATE_TYPES = new Set(['date', 'datetime', 'datetime2', 'smalldatetime', 'datetimeoffset']);
|
|
54
|
+
/**
|
|
55
|
+
* `value` converted to what a parameter of database type `sqlType` binds: a boolean for a bit or
|
|
56
|
+
* boolean column, a finite number for a numeric one, a `Date` for a date or timestamp one, and text
|
|
57
|
+
* otherwise. Undefined when the value cannot be one (a non-numeric string for an int column, an
|
|
58
|
+
* invalid date), so the caller can refuse rather than bind a value the database would reject or
|
|
59
|
+
* read differently.
|
|
60
|
+
*
|
|
61
|
+
* @param value - The value, in native form (booleans as booleans, dates as `Date` or ISO text with its zone).
|
|
62
|
+
* @param sqlType - The column's type as the server describes it, such as `varchar(50)` or `timestamp with time zone`.
|
|
63
|
+
*/
|
|
64
|
+
export function TypedBindValue(value, sqlType) {
|
|
65
|
+
const base = baseTypeName(sqlType);
|
|
66
|
+
if (BOOLEAN_TYPES.has(base))
|
|
67
|
+
return booleanValue(value);
|
|
68
|
+
if (NUMERIC_TYPES.has(base)) {
|
|
69
|
+
const n = typeof value === 'number' ? value : typeof value === 'string' && value.trim().length > 0 ? Number(value.trim()) : NaN;
|
|
70
|
+
return Number.isFinite(n) ? n : undefined;
|
|
71
|
+
}
|
|
72
|
+
if (DATE_TYPES.has(base) || base.startsWith('timestamp')) {
|
|
73
|
+
const d = value instanceof Date ? value : typeof value === 'string' ? dateFromText(value) : null;
|
|
74
|
+
return d && !Number.isNaN(d.getTime()) ? d : undefined;
|
|
75
|
+
}
|
|
76
|
+
return textValue(value);
|
|
77
|
+
}
|
|
78
|
+
/** ISO text with no zone: `2026-01-02`, `2026-01-02 10:30`, `2026-01-02T10:30:00.123`. */
|
|
79
|
+
const ZONELESS_ISO = /^(\d{4}-\d{2}-\d{2})(?:[T ](\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?))?$/;
|
|
80
|
+
/** ISO text ending in a zone: `Z`, `+02:00`, `-0500`. */
|
|
81
|
+
const ZONED_ISO = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})$/i;
|
|
82
|
+
/**
|
|
83
|
+
* The instant ISO text names. Text with no zone reads as that wall-clock time in UTC, which is what
|
|
84
|
+
* the database reads from the same text as a literal (drivers send a `Date` as its UTC parts). Any
|
|
85
|
+
* other text is refused (null): a locale format could read differently here and in the database.
|
|
86
|
+
*/
|
|
87
|
+
function dateFromText(text) {
|
|
88
|
+
const trimmed = text.trim();
|
|
89
|
+
const zoneless = ZONELESS_ISO.exec(trimmed);
|
|
90
|
+
if (zoneless)
|
|
91
|
+
return new Date(`${zoneless[1]}T${zoneless[2] ?? '00:00:00'}Z`);
|
|
92
|
+
return ZONED_ISO.test(trimmed) ? new Date(trimmed.replace(' ', 'T')) : null;
|
|
93
|
+
}
|
|
94
|
+
/** The base type name: lower case, without arguments or a trailing `[]`. */
|
|
95
|
+
function baseTypeName(sqlType) {
|
|
96
|
+
const open = sqlType.indexOf('(');
|
|
97
|
+
return (open < 0 ? sqlType : sqlType.slice(0, open)).replace(/\[\]$/, '').trim().toLowerCase();
|
|
98
|
+
}
|
|
99
|
+
function booleanValue(value) {
|
|
100
|
+
if (typeof value === 'boolean')
|
|
101
|
+
return value;
|
|
102
|
+
if (value === 1 || value === 0)
|
|
103
|
+
return value === 1;
|
|
104
|
+
if (typeof value === 'string') {
|
|
105
|
+
const text = value.trim().toLowerCase();
|
|
106
|
+
if (text === 'true' || text === '1')
|
|
107
|
+
return true;
|
|
108
|
+
if (text === 'false' || text === '0')
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
function textValue(value) {
|
|
114
|
+
if (typeof value === 'string')
|
|
115
|
+
return value;
|
|
116
|
+
if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint')
|
|
117
|
+
return String(value);
|
|
118
|
+
if (value instanceof Date)
|
|
119
|
+
return value.toISOString();
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=typedQueryParameter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typedQueryParameter.js","sourceRoot":"","sources":["../src/typedQueryParameter.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,OAAO,mBAAmB;IAC5B;IACI,mFAAmF;IACnE,IAAY;IAC5B,qDAAqD;IACrC,OAAe,EACf,KAA+B;QAH/B,SAAI,GAAJ,IAAI,CAAQ;QAEZ,YAAO,GAAP,OAAO,CAAQ;QACf,UA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AI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,GAAG;YAAE,OAAO,KAAK,CAAC;IACvD,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC7B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/G,IAAI,KAAK,YAAY,IAAI;QAAE,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IACtD,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -6,6 +6,19 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module @memberjunction/generic-database-provider/types
|
|
8
8
|
*/
|
|
9
|
+
/**
|
|
10
|
+
* One schema-name to Flyway-placeholder rule for a migration-formatted SQL log. Same shape as
|
|
11
|
+
* `SQLOutput.schemaPlaceholders` in `mj.config.cjs`, so a repo declares the mapping once and
|
|
12
|
+
* CodeGen and the SQL logger read the same array. They apply it differently: CodeGen goes in
|
|
13
|
+
* declared order and needs no `.` after the schema name; the SQL logger needs the `.` and skips a
|
|
14
|
+
* name preceded by a word character, `$`, `@` or `#`.
|
|
15
|
+
*/
|
|
16
|
+
export interface SqlSchemaPlaceholder {
|
|
17
|
+
/** The schema name as it appears in captured SQL, e.g. `__mj_BizAppsAccounting` */
|
|
18
|
+
schema: string;
|
|
19
|
+
/** The placeholder written in its place, e.g. `${flyway:defaultSchema}` or `${mjSchema}` */
|
|
20
|
+
placeholder: string;
|
|
21
|
+
}
|
|
9
22
|
/**
|
|
10
23
|
* Configuration options for SQL logging sessions
|
|
11
24
|
*/
|
|
@@ -15,8 +28,39 @@ export interface SqlLoggingOptions {
|
|
|
15
28
|
/**
|
|
16
29
|
* Optional default schema name to use for Flyway migrations for replacing schema names with
|
|
17
30
|
* the placeholder ${flyway:defaultSchema}
|
|
31
|
+
*
|
|
32
|
+
* Used only when `schemaPlaceholders` is absent or empty.
|
|
18
33
|
*/
|
|
19
34
|
defaultSchemaName?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Schema-to-placeholder rules for migration formatting (#3618). When set, they replace the
|
|
37
|
+
* single `defaultSchemaName` -> `${flyway:defaultSchema}` rewrite.
|
|
38
|
+
*
|
|
39
|
+
* `${flyway:defaultSchema}` is the core schema in MJ's own repo, but in an Open App repo Skyway
|
|
40
|
+
* binds it to the app schema and `${mjSchema}` to core. An Open App therefore supplies both:
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* schemaPlaceholders: [
|
|
44
|
+
* { schema: '__mj_BizAppsAccounting', placeholder: '${flyway:defaultSchema}' },
|
|
45
|
+
* { schema: '__mj', placeholder: '${mjSchema}' },
|
|
46
|
+
* ]
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* The rules run in one pass, so an emitted placeholder is never rewritten again. A schema name
|
|
50
|
+
* is rewritten only when a `.` follows it (optionally after a closing `]`), which also keeps a
|
|
51
|
+
* short rule off the prefix of a longer schema name, and no word character, `$`, `@` or `#`
|
|
52
|
+
* precedes it. Code and string data are treated alike: `__mj.` inside a quoted literal is
|
|
53
|
+
* rewritten; a bare name with no `.` after it is left alone.
|
|
54
|
+
*
|
|
55
|
+
* Ignored unless `formatAsMigration` is true.
|
|
56
|
+
*/
|
|
57
|
+
schemaPlaceholders?: SqlSchemaPlaceholder[];
|
|
58
|
+
/**
|
|
59
|
+
* Escape `${...}` inside SQL string literals so Flyway/Skyway does not read captured data
|
|
60
|
+
* (template text, prompt bodies) as a placeholder. Always on when `formatAsMigration` is true;
|
|
61
|
+
* set it to get the escaping without migration formatting.
|
|
62
|
+
*/
|
|
63
|
+
escapeFlywaySyntax?: boolean;
|
|
20
64
|
/** Optional description to include as a comment at the start of the log */
|
|
21
65
|
description?: string;
|
|
22
66
|
/** Which types of statements to log: 'queries' (all), 'mutations' (only data changes), 'both' (default) */
|
|
@@ -74,8 +118,9 @@ export interface SqlLoggingOptions {
|
|
|
74
118
|
/**
|
|
75
119
|
* Optional rewrite of each logged text before the session reads it: the statement, its simple-SQL
|
|
76
120
|
* fallback, the description and the `-- Parameters:` line. It runs before the verbose prints, the
|
|
77
|
-
* filters, the Flyway escape and the pretty-print, so text it
|
|
78
|
-
* or the console
|
|
121
|
+
* filters, the Flyway escape, the schema-placeholder rewrite and the pretty-print, so text it
|
|
122
|
+
* removes never reaches the log file or the console, and SQL it adds that names a real schema
|
|
123
|
+
* (`[__mj].Entity`) is rewritten to that schema's placeholder like the rest of the statement.
|
|
79
124
|
*
|
|
80
125
|
* It covers only this session's file and verbose prints, plus the provider's shared verbose
|
|
81
126
|
* `Query to log:` print. Other sessions and other output paths do not use it.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,mFAAmF;IACnF,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,mFAAmF;IACnF,MAAM,EAAE,MAAM,CAAC;IACf,4FAA4F;IAC5F,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,mFAAmF;IACnF,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,kBAAkB,CAAC,EAAE,oBAAoB,E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OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/generic-database-provider",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.2.0-edge.
|
|
4
|
+
"version": "6.2.0-edge.7",
|
|
5
5
|
"description": "Shared database provider logic for MemberJunction — intermediate base class between DatabaseProviderBase and platform-specific providers",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -16,19 +16,19 @@
|
|
|
16
16
|
"vitest": "^3.1.1"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@memberjunction/actions": "6.2.0-edge.
|
|
20
|
-
"@memberjunction/actions-base": "6.2.0-edge.
|
|
21
|
-
"@memberjunction/ai-vectors-memory": "6.2.0-edge.
|
|
22
|
-
"@memberjunction/aiengine": "6.2.0-edge.
|
|
23
|
-
"@memberjunction/core": "6.2.0-edge.
|
|
24
|
-
"@memberjunction/core-entities": "6.2.0-edge.
|
|
25
|
-
"@memberjunction/encryption": "6.2.0-edge.
|
|
26
|
-
"@memberjunction/geo-core": "6.2.0-edge.
|
|
27
|
-
"@memberjunction/global": "6.2.0-edge.
|
|
28
|
-
"@memberjunction/query-processor": "6.2.0-edge.
|
|
29
|
-
"@memberjunction/sql-dialect": "6.2.0-edge.
|
|
30
|
-
"@memberjunction/sql-parser": "6.2.0-edge.
|
|
31
|
-
"@memberjunction/queue": "6.2.0-edge.
|
|
19
|
+
"@memberjunction/actions": "6.2.0-edge.7",
|
|
20
|
+
"@memberjunction/actions-base": "6.2.0-edge.7",
|
|
21
|
+
"@memberjunction/ai-vectors-memory": "6.2.0-edge.7",
|
|
22
|
+
"@memberjunction/aiengine": "6.2.0-edge.7",
|
|
23
|
+
"@memberjunction/core": "6.2.0-edge.7",
|
|
24
|
+
"@memberjunction/core-entities": "6.2.0-edge.7",
|
|
25
|
+
"@memberjunction/encryption": "6.2.0-edge.7",
|
|
26
|
+
"@memberjunction/geo-core": "6.2.0-edge.7",
|
|
27
|
+
"@memberjunction/global": "6.2.0-edge.7",
|
|
28
|
+
"@memberjunction/query-processor": "6.2.0-edge.7",
|
|
29
|
+
"@memberjunction/sql-dialect": "6.2.0-edge.7",
|
|
30
|
+
"@memberjunction/sql-parser": "6.2.0-edge.7",
|
|
31
|
+
"@memberjunction/queue": "6.2.0-edge.7",
|
|
32
32
|
"sql-formatter": "^15.7.0",
|
|
33
33
|
"uuid": "^13.0.0"
|
|
34
34
|
},
|