@snowtop/ent 0.2.9 → 0.2.10

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/core/ent.js CHANGED
@@ -133,12 +133,15 @@ function createAssocEdgeConfigLoader(options) {
133
133
  if (!ids.length) {
134
134
  return [];
135
135
  }
136
+ // DataLoader exposes readonly batch keys; clone once so downstream query helpers
137
+ // can keep their mutable-array signatures.
138
+ const keys = [...ids];
136
139
  let col = options.key;
137
140
  // defaults to uuid
138
141
  let typ = options.keyType || "uuid";
139
142
  const rowOptions = {
140
143
  ...options,
141
- clause: clause.DBTypeIn(col, ids, typ),
144
+ clause: clause.DBTypeIn(col, keys, typ),
142
145
  };
143
146
  // TODO is there a better way of doing this?
144
147
  // context not needed because we're creating a loader which has its own cache which is being used here
@@ -150,7 +153,7 @@ function createAssocEdgeConfigLoader(options) {
150
153
  rowMap.set(key, node);
151
154
  }
152
155
  }
153
- return ids.map((id) => rowMap.get(id) ?? null);
156
+ return keys.map((id) => rowMap.get(id) ?? null);
154
157
  }, loaderOptions, options.tableName);
155
158
  }
156
159
  // used to wrap errors that would eventually be thrown in ents
@@ -185,8 +188,9 @@ function createEntLoader(viewer, options, map) {
185
188
  if (!ids.length) {
186
189
  return [];
187
190
  }
191
+ const keys = [...ids];
188
192
  const loader = options.loaderFactory.createLoader(viewer.context);
189
- const rows = await loader.loadMany(ids);
193
+ const rows = await loader.loadMany(keys);
190
194
  // this is a loader which should return the same order based on passed-in ids
191
195
  // so let's depend on that...
192
196
  return (0, async_utils_1.mapWithConcurrency)(rows, getEntLoaderPrivacyConcurrencyLimit(), async (row, idx) => {
@@ -200,9 +204,9 @@ function createEntLoader(viewer, options, map) {
200
204
  }
201
205
  if (!row) {
202
206
  if (tableName) {
203
- return new ErrorWrapper(new Error(`couldn't find row for value ${ids[idx]} in table ${tableName}`));
207
+ return new ErrorWrapper(new Error(`couldn't find row for value ${keys[idx]} in table ${tableName}`));
204
208
  }
205
- return new ErrorWrapper(new Error(`couldn't find row for value ${ids[idx]}`));
209
+ return new ErrorWrapper(new Error(`couldn't find row for value ${keys[idx]}`));
206
210
  }
207
211
  const r = await applyPrivacyPolicyForRowImpl(viewer, options, row);
208
212
  if (rowIsError(r)) {
@@ -1,5 +1,4 @@
1
- import { type Pool } from "pg";
2
- import type { RuntimeDBExtension } from "./config";
1
+ import type { PostgresDriver, RuntimeDBExtension } from "./config";
3
2
  import type { ResolvedDevSchema } from "./dev_schema";
4
3
  export interface InstalledDBExtension {
5
4
  name: string;
@@ -16,10 +15,16 @@ export interface ExtensionRuntimeHandler {
16
15
  types?: ExtensionTypeParser[];
17
16
  validate?(installed: InstalledDBExtension, extension: RuntimeDBExtension): void | Promise<void>;
18
17
  }
18
+ interface Queryable {
19
+ query<R extends Record<string, any> = any>(query: string, values?: any[]): Promise<{
20
+ rows: R[];
21
+ }>;
22
+ }
19
23
  export declare function registerExtensionRuntime(handler: ExtensionRuntimeHandler): void;
20
24
  export declare function clearExtensionRuntimes(): void;
21
25
  export declare function normalizeExtensions(extensions: RuntimeDBExtension[]): RuntimeDBExtension[];
22
26
  export declare function resolveExtensions(cfg?: RuntimeDBExtension[]): RuntimeDBExtension[];
23
27
  export declare function getExtensionSearchPathSchemas(extensions: RuntimeDBExtension[]): string[];
24
28
  export declare function buildExtensionSearchPath(resolvedDevSchema: ResolvedDevSchema, extensions: RuntimeDBExtension[]): string | undefined;
25
- export declare function initializeExtensions(pool: Pick<Pool, "query">, extensions: RuntimeDBExtension[]): Promise<void>;
29
+ export declare function initializeExtensions(pool: Queryable, extensions: RuntimeDBExtension[], postgresDriver?: PostgresDriver): Promise<void>;
30
+ export {};
@@ -197,7 +197,7 @@ async function initializeRegisteredTypeParsers(pool, configuredExtensions) {
197
197
  registerArrayParser(row.typarray, typeHandler.parse);
198
198
  }
199
199
  }
200
- async function initializeExtensions(pool, extensions) {
200
+ async function initializeExtensions(pool, extensions, postgresDriver = "pg") {
201
201
  const normalizedExtensions = normalizeExtensions(extensions);
202
202
  const configuredExtensions = new Map(normalizedExtensions.map((extension) => [extension.name, extension]));
203
203
  const installedExtensions = await getInstalledExtensions(pool, normalizedExtensions);
@@ -216,5 +216,14 @@ async function initializeExtensions(pool, extensions) {
216
216
  const handler = runtimeHandlers.get(extension.name);
217
217
  await handler?.validate?.(installed, extension);
218
218
  }
219
+ if (postgresDriver === "bun") {
220
+ const unsupportedExtensions = normalizedExtensions
221
+ .filter((extension) => (runtimeHandlers.get(extension.name)?.types || []).length > 0)
222
+ .map((extension) => extension.name);
223
+ if (unsupportedExtensions.length > 0) {
224
+ throw new Error(`postgresDriver "bun" does not support extension runtime type parsers for: ${unsupportedExtensions.join(", ")}`);
225
+ }
226
+ return;
227
+ }
219
228
  await initializeRegisteredTypeParsers(pool, configuredExtensions);
220
229
  }
@@ -23,7 +23,7 @@ function isGlobalSchemaField(f) {
23
23
  function setGlobalSchema(val) {
24
24
  globalSchema = val;
25
25
  if (val.fields) {
26
- for (const [k, v] of Object.entries(val.fields)) {
26
+ for (const [_k, v] of Object.entries(val.fields)) {
27
27
  if (isGlobalSchemaField(v) && v.type.type) {
28
28
  globalSchemaFields.set(v.type.type, v);
29
29
  }
@@ -33,13 +33,13 @@ export declare class BoundedCacheMap<K, V> {
33
33
  }
34
34
  export declare function createBoundedCacheMap<K, V>(cacheMap: CacheMapLike<K, V>, cacheKeyFn?: CacheKeyFn<K>): CacheMapLike<K, V>;
35
35
  export declare function createLoaderCacheMap<K, V>(options: DataOptions): CacheMapLike<K, V>;
36
- export declare class CacheMap {
36
+ export declare class CacheMap<K, V> implements CacheMapLike<K, V> {
37
37
  private options;
38
38
  private m;
39
39
  constructor(options: DataOptions);
40
- get(key: any): any;
41
- set(key: any, value: any): Map<any, any>;
42
- delete(key: any): boolean;
40
+ get(key: K): V | undefined;
41
+ set(key: K, value: V): Map<K, V>;
42
+ delete(key: K): boolean;
43
43
  clear(): void;
44
44
  }
45
45
  export {};
package/core/logger.js CHANGED
@@ -26,18 +26,20 @@ function clearLogLevels() {
26
26
  }
27
27
  function log(level, msg) {
28
28
  if (logLevels.has(level)) {
29
+ const method = m[level];
29
30
  // mostly for sqlite error but fine for any type of error
30
31
  if (level == "error" && msg instanceof Error && msg.message !== undefined) {
31
32
  console.error(msg.message);
32
33
  return;
33
34
  }
34
35
  // console[m[level]](inspect(msg, false, 10));
35
- console[m[level]](msg);
36
+ console[method](msg);
36
37
  }
37
38
  }
38
39
  function logIf(level, logFn) {
39
40
  if (logLevels.has(level)) {
40
- console[m[level]](logFn());
41
+ const method = m[level];
42
+ console[method](logFn());
41
43
  }
42
44
  }
43
45
  function logTrace() {
package/core/privacy.d.ts CHANGED
@@ -86,18 +86,14 @@ export declare class AllowIfEntIsNotVisibleRule<TEnt extends Ent<TViewer>, TView
86
86
  export declare class AllowIfEntIsVisiblePolicy<TEnt extends Ent<TViewer>, TViewer extends Viewer> implements PrivacyPolicy<TEnt, TViewer> {
87
87
  private id;
88
88
  private options;
89
+ rules: PrivacyPolicyRule[];
89
90
  constructor(id: ID, options: LoadEntOptions<TEnt, TViewer>);
90
- rules: {
91
- apply(_v: Viewer, _ent?: Ent): Promise<PrivacyResult>;
92
- }[];
93
91
  }
94
92
  export declare class DenyIfEntIsVisiblePolicy<TEnt extends Ent<TViewer>, TViewer extends Viewer> implements PrivacyPolicy<TEnt, TViewer> {
95
93
  private id;
96
94
  private options;
95
+ rules: PrivacyPolicyRule[];
97
96
  constructor(id: ID, options: LoadEntOptions<TEnt, TViewer>);
98
- rules: {
99
- apply(_v: Viewer, _ent?: Ent): Promise<PrivacyResult>;
100
- }[];
101
97
  }
102
98
  export declare class DenyIfEntIsVisibleRule<TEnt extends Ent<TViewer>, TViewer extends Viewer> implements PrivacyPolicyRule<TEnt, TViewer> {
103
99
  private id;
package/core/privacy.js CHANGED
@@ -225,7 +225,10 @@ class AllowIfEntIsVisiblePolicy {
225
225
  constructor(id, options) {
226
226
  this.id = id;
227
227
  this.options = options;
228
- this.rules = [new AllowIfEntIsVisibleRule(this.id, this.options), exports.AlwaysDenyRule];
228
+ this.rules = [
229
+ new AllowIfEntIsVisibleRule(this.id, this.options),
230
+ exports.AlwaysDenyRule,
231
+ ];
229
232
  }
230
233
  }
231
234
  exports.AllowIfEntIsVisiblePolicy = AllowIfEntIsVisiblePolicy;
@@ -233,7 +236,10 @@ class DenyIfEntIsVisiblePolicy {
233
236
  constructor(id, options) {
234
237
  this.id = id;
235
238
  this.options = options;
236
- this.rules = [new DenyIfEntIsVisibleRule(this.id, this.options), exports.AlwaysAllowRule];
239
+ this.rules = [
240
+ new DenyIfEntIsVisibleRule(this.id, this.options),
241
+ exports.AlwaysAllowRule,
242
+ ];
237
243
  }
238
244
  }
239
245
  exports.DenyIfEntIsVisiblePolicy = DenyIfEntIsVisiblePolicy;
@@ -1,4 +1,6 @@
1
- export { EdgeQuery, BaseEdgeQuery, EdgeQueryFilter, PaginationInfo, } from "./query";
2
- export { AssocEdgeQueryBase, EdgeQuerySource } from "./assoc_query";
1
+ export { BaseEdgeQuery, } from "./query";
2
+ export type { EdgeQuery, EdgeQueryFilter, PaginationInfo } from "./query";
3
+ export { AssocEdgeQueryBase } from "./assoc_query";
4
+ export type { EdgeQuerySource } from "./assoc_query";
3
5
  export { CustomEdgeQueryBase } from "./custom_query";
4
6
  export { CustomClauseQuery } from "./custom_clause_query";
@@ -192,6 +192,8 @@ export declare class GQLCapture {
192
192
  static getCustomInterfaces(): Map<string, CustomObject>;
193
193
  static getCustomUnions(): Map<string, CustomObject>;
194
194
  static getCustomTypes(): Map<string, CustomType>;
195
+ private static normalizeClassDecoratorContext;
196
+ private static normalizeMemberDecoratorContext;
195
197
  private static getNullableArg;
196
198
  static getProcessedCustomFields(): ProcessCustomFieldMap;
197
199
  static getProcessedCustomMutations(): ProcessedCustomField[];
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.gqlFileUpload = exports.gqlConnection = exports.gqlContextType = exports.gqlMutation = exports.gqlQuery = exports.gqlUnionType = exports.gqlInterfaceType = exports.gqlObjectType = exports.gqlInputObjectType = exports.gqlArgType = exports.gqlField = exports.GQLCapture = exports.addCustomType = exports.isCustomType = exports.knownInterfaces = exports.knownDisAllowedNames = exports.knownAllowedNames = exports.CustomFieldType = void 0;
4
- const graphql_1 = require("graphql");
5
4
  const parse_1 = require("../parse_schema/parse");
6
5
  var CustomFieldType;
7
6
  (function (CustomFieldType) {
@@ -62,10 +61,17 @@ const isCustomType = (type) => {
62
61
  };
63
62
  exports.isCustomType = isCustomType;
64
63
  const isGraphQLScalarType = (type) => {
65
- return (0, graphql_1.isScalarType)(type);
64
+ return !!type &&
65
+ typeof type === "object" &&
66
+ typeof type.serialize === "function" &&
67
+ typeof type.parseValue === "function" &&
68
+ typeof type.parseLiteral === "function";
66
69
  };
67
70
  const isGraphQLEnumType = (type) => {
68
- return (0, graphql_1.isEnumType)(type);
71
+ return (!!type &&
72
+ typeof type === "object" &&
73
+ typeof type.getValues === "function" &&
74
+ typeof type.toConfig === "function");
69
75
  };
70
76
  const addCustomType = async (type, gqlCapture) => {
71
77
  // TODO these should return ReadOnly objects...
@@ -102,12 +108,21 @@ const addCustomType = async (type, gqlCapture) => {
102
108
  }
103
109
  catch (e) {
104
110
  if (type.secondaryImportPath) {
105
- await (0, exports.addCustomType)({
106
- ...type,
107
- importPath: type.secondaryImportPath,
108
- }, gqlCapture);
111
+ try {
112
+ const r = require(type.secondaryImportPath);
113
+ const ct = r[type.type];
114
+ if (ct && isGraphQLScalarType(ct)) {
115
+ type.scalarInfo = {
116
+ description: ct.description,
117
+ name: ct.name,
118
+ };
119
+ if (ct.specifiedByURL) {
120
+ type.scalarInfo.specifiedByUrl = ct.specifiedByURL;
121
+ }
122
+ }
123
+ }
124
+ catch { }
109
125
  }
110
- return;
111
126
  }
112
127
  }
113
128
  if (customType) {
@@ -145,8 +160,8 @@ const getType = (typ, result) => {
145
160
  return;
146
161
  }
147
162
  // GraphQLScalarType or GraphQLEnumType or ClassType
148
- result.scalarType = isGraphQLScalarType(typ);
149
163
  result.enumType = isGraphQLEnumType(typ);
164
+ result.scalarType = !result.enumType && isGraphQLScalarType(typ);
150
165
  result.type = typ.name;
151
166
  return;
152
167
  };
@@ -195,6 +210,55 @@ class GQLCapture {
195
210
  static getCustomTypes() {
196
211
  return this.customTypes;
197
212
  }
213
+ static normalizeClassDecoratorContext(target, ctx) {
214
+ if (ctx && typeof ctx === "object" && ctx.kind === "class" && ctx.name) {
215
+ return {
216
+ kind: "class",
217
+ name: ctx.name,
218
+ };
219
+ }
220
+ if (typeof target === "function" && target.name) {
221
+ return {
222
+ kind: "class",
223
+ name: target.name,
224
+ };
225
+ }
226
+ return null;
227
+ }
228
+ static normalizeMemberDecoratorContext(target, ctxOrProperty, descriptor) {
229
+ if (ctxOrProperty &&
230
+ typeof ctxOrProperty === "object" &&
231
+ "kind" in ctxOrProperty &&
232
+ (ctxOrProperty.kind === "method" ||
233
+ ctxOrProperty.kind === "field" ||
234
+ ctxOrProperty.kind === "getter")) {
235
+ return {
236
+ kind: ctxOrProperty.kind,
237
+ name: ctxOrProperty.name,
238
+ static: ctxOrProperty.static,
239
+ private: ctxOrProperty.private,
240
+ };
241
+ }
242
+ if (typeof ctxOrProperty !== "string" &&
243
+ typeof ctxOrProperty !== "symbol") {
244
+ return null;
245
+ }
246
+ let kind = "field";
247
+ if (descriptor) {
248
+ if (typeof descriptor.value === "function") {
249
+ kind = "method";
250
+ }
251
+ else if (typeof descriptor.get === "function") {
252
+ kind = "getter";
253
+ }
254
+ }
255
+ return {
256
+ kind,
257
+ name: ctxOrProperty,
258
+ static: typeof target === "function",
259
+ private: false,
260
+ };
261
+ }
198
262
  static getNullableArg(fd) {
199
263
  let res = fd;
200
264
  if (fd.nullable === undefined) {
@@ -286,8 +350,10 @@ class GQLCapture {
286
350
  return result;
287
351
  }
288
352
  static gqlField(options) {
289
- return function (_target, ctx) {
353
+ return function (target, ctxOrProperty, descriptor) {
354
+ const ctx = GQLCapture.normalizeMemberDecoratorContext(target, ctxOrProperty, descriptor);
290
355
  if (!GQLCapture.isEnabled() ||
356
+ !ctx ||
291
357
  (ctx.kind !== "method" &&
292
358
  ctx.kind !== "field" &&
293
359
  ctx.kind !== "getter") ||
@@ -375,34 +441,35 @@ class GQLCapture {
375
441
  }
376
442
  static gqlArgType(options) {
377
443
  return function (target, ctx) {
378
- return GQLCapture.customGQLObject(ctx, GQLCapture.customArgs, options);
444
+ return GQLCapture.customGQLObject(target, ctx, GQLCapture.customArgs, options);
379
445
  };
380
446
  }
381
447
  static gqlInputObjectType(options) {
382
448
  return function (target, ctx) {
383
- return GQLCapture.customGQLObject(ctx, GQLCapture.customInputObjects, options);
449
+ return GQLCapture.customGQLObject(target, ctx, GQLCapture.customInputObjects, options);
384
450
  };
385
451
  }
386
452
  static gqlObjectType(options) {
387
453
  return function (target, ctx) {
388
- return GQLCapture.customGQLObject(ctx, GQLCapture.customObjects, options);
454
+ return GQLCapture.customGQLObject(target, ctx, GQLCapture.customObjects, options);
389
455
  };
390
456
  }
391
457
  static gqlUnionType(options) {
392
458
  return function (target, ctx) {
393
- return GQLCapture.customGQLObject(ctx, GQLCapture.customUnions, options);
459
+ return GQLCapture.customGQLObject(target, ctx, GQLCapture.customUnions, options);
394
460
  };
395
461
  }
396
462
  static gqlInterfaceType(options) {
397
463
  return function (target, ctx) {
398
- return GQLCapture.customGQLObject(ctx, GQLCapture.customInterfaces, options);
464
+ return GQLCapture.customGQLObject(target, ctx, GQLCapture.customInterfaces, options);
399
465
  };
400
466
  }
401
- static customGQLObject(ctx, map, options) {
402
- if (!GQLCapture.isEnabled() || ctx.kind !== "class" || !ctx.name) {
467
+ static customGQLObject(target, ctx, map, options) {
468
+ const normalized = GQLCapture.normalizeClassDecoratorContext(target, ctx);
469
+ if (!GQLCapture.isEnabled() || !normalized) {
403
470
  return;
404
471
  }
405
- let className = ctx.name.toString();
472
+ let className = normalized.name.toString();
406
473
  let nodeName = options?.name || className;
407
474
  map.set(className, {
408
475
  className,
@@ -416,16 +483,18 @@ class GQLCapture {
416
483
  }
417
484
  // we want to specify args if any, name, response if any
418
485
  static gqlQuery(options) {
419
- return function (target, ctx) {
420
- if (!GQLCapture.isEnabled()) {
486
+ return function (target, ctxOrProperty, descriptor) {
487
+ const ctx = GQLCapture.normalizeMemberDecoratorContext(target, ctxOrProperty, descriptor);
488
+ if (!GQLCapture.isEnabled() || !ctx || ctx.kind !== "method") {
421
489
  return;
422
490
  }
423
491
  GQLCapture.customQueries.push(GQLCapture.getCustomField(ctx, options));
424
492
  };
425
493
  }
426
494
  static gqlMutation(options) {
427
- return function (target, ctx) {
428
- if (!GQLCapture.isEnabled()) {
495
+ return function (target, ctxOrProperty, descriptor) {
496
+ const ctx = GQLCapture.normalizeMemberDecoratorContext(target, ctxOrProperty, descriptor);
497
+ if (!GQLCapture.isEnabled() || !ctx || ctx.kind !== "method") {
429
498
  return;
430
499
  }
431
500
  GQLCapture.customMutations.push(GQLCapture.getCustomField(ctx, options, true));
@@ -1,12 +1,15 @@
1
- export { gqlFieldOptions, gqlObjectOptions, gqlField, gqlArgType, gqlInputObjectType, gqlObjectType, gqlQuery, gqlMutation, gqlContextType, gqlConnection, GraphQLConnection, GQLCapture, gqlFileUpload, CustomType, gqlInterfaceType, gqlUnionType, } from "./graphql";
1
+ export { gqlField, gqlArgType, gqlInputObjectType, gqlObjectType, gqlQuery, gqlMutation, gqlContextType, gqlConnection, GQLCapture, gqlFileUpload, gqlInterfaceType, gqlUnionType, } from "./graphql";
2
+ export type { CustomType, GraphQLConnection, gqlFieldOptions, gqlObjectOptions, } from "./graphql";
2
3
  export { GraphQLTime } from "./scalars/time";
3
4
  export { GraphQLDate } from "./scalars/date";
4
5
  export { GraphQLOrderByDirection } from "./scalars/orderby_direction";
5
6
  export { GraphQLPageInfo } from "./query/page_info";
6
- export { GraphQLEdge, GraphQLEdgeConnection } from "./query/edge_connection";
7
+ export { GraphQLEdgeConnection } from "./query/edge_connection";
8
+ export type { GraphQLEdge } from "./query/edge_connection";
7
9
  export { GraphQLEdgeType, GraphQLConnectionType, } from "./query/connection_type";
8
10
  export { GraphQLNodeInterface } from "./builtins/node";
9
11
  export { GraphQLConnectionInterface } from "./builtins/connection";
10
12
  export { GraphQLEdgeInterface } from "./builtins/edge";
11
- export { NodeResolver, EntNodeResolver, registerResolver, clearResolvers, resolveID, nodeIDEncoder, mustDecodeIDFromGQLID, mustDecodeNullableIDFromGQLID, encodeGQLID, } from "./node_resolver";
13
+ export { EntNodeResolver, registerResolver, clearResolvers, resolveID, nodeIDEncoder, mustDecodeIDFromGQLID, mustDecodeNullableIDFromGQLID, encodeGQLID, } from "./node_resolver";
14
+ export type { NodeResolver } from "./node_resolver";
12
15
  export { transformUnionTypes } from "./mutations/union";
package/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export * from "./core/base";
2
- export { loadEnt, loadCustomData, loadCustomEnts, loadCustomCount, loadEntX, loadEnts, CustomQuery, loadDerivedEnt, loadDerivedEntX, loadEntViaKey, loadEntXViaKey, performRawQuery, loadRowX, loadRow, loadRows, AssocEdge, AssocEdgeData, loadEdgeData, loadEdgeDatas, loadEdges, loadUniqueEdge, loadUniqueNode, loadRawEdgeCountX, loadEdgeForID2, loadNodesByEdge, getEdgeTypeInGroup, setEntLoaderPrivacyConcurrencyLimit, getEntLoaderPrivacyConcurrencyLimit, } from "./core/ent";
3
- export { DataOperation, EditNodeOptions, EditNodeOperation, RawQueryOperation, EdgeOperation, DeleteNodeOperation, AssocEdgeInputOptions, AssocEdgeInput, } from "./action/operations";
2
+ export { loadEnt, loadCustomData, loadCustomEnts, loadCustomCount, loadEntX, loadEnts, loadDerivedEnt, loadDerivedEntX, loadEntViaKey, loadEntXViaKey, performRawQuery, loadRowX, loadRow, loadRows, AssocEdge, AssocEdgeData, loadEdgeData, loadEdgeDatas, loadEdges, loadUniqueEdge, loadUniqueNode, loadRawEdgeCountX, loadEdgeForID2, loadNodesByEdge, getEdgeTypeInGroup, setEntLoaderPrivacyConcurrencyLimit, getEntLoaderPrivacyConcurrencyLimit, } from "./core/ent";
3
+ export type { CustomQuery } from "./core/ent";
4
+ export { EditNodeOperation, RawQueryOperation, EdgeOperation, DeleteNodeOperation, } from "./action/operations";
5
+ export type { AssocEdgeInput, AssocEdgeInputOptions, DataOperation, EditNodeOptions, } from "./action/operations";
4
6
  export { setGlobalSchema } from "./core/global_schema";
5
7
  export { registerExtensionRuntime } from "./core/extensions";
6
8
  import DB from "./core/db";
@@ -12,7 +14,8 @@ export * from "./core/query_impl";
12
14
  export type { QueryExpression } from "./core/query_expression";
13
15
  export * from "./schema/";
14
16
  import * as q from "./core/clause";
15
- export { Clause, Expression, ParameterizedExpression } from "./core/clause";
17
+ export { Expression, ParameterizedExpression } from "./core/clause";
18
+ export type { Clause } from "./core/clause";
16
19
  declare const query: {
17
20
  Eq: typeof q.Eq;
18
21
  NotEq: typeof q.NotEq;
@@ -56,8 +59,10 @@ declare const query: {
56
59
  ParameterizedExpression: typeof q.ParameterizedExpression;
57
60
  };
58
61
  export { query };
59
- export { RequestContext, ContextCache } from "./core/context";
60
- export { IDViewer, LoggedOutViewer, IDViewerOptions } from "./core/viewer";
62
+ export { ContextCache } from "./core/context";
63
+ export type { RequestContext } from "./core/context";
64
+ export { IDViewer, LoggedOutViewer } from "./core/viewer";
65
+ export type { IDViewerOptions } from "./core/viewer";
61
66
  export { loadConfig } from "./core/config";
62
67
  export { setLogLevels } from "./core/logger";
63
68
  export * from "./core/metrics";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowtop/ent",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "snowtop ent framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,5 +1,5 @@
1
1
  import { FieldMap, Pattern, FieldOverrideMap } from "./schema";
2
- import { Action, AssocEdgeGroup, Constraint, Edge, Index, Schema } from ".";
2
+ import type { Action, AssocEdgeGroup, Constraint, Edge, Index, Schema } from "./schema";
3
3
  import { PrivacyPolicy } from "../core/base";
4
4
  export declare const Timestamps: Pattern;
5
5
  export declare const Node: Pattern;
package/schema/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import Schema from "./schema";
2
- export { Schema };
3
- export { Field, AssocEdge, AssocEdgeGroup, InverseAssocEdge, Edge, Pattern, DBType, Type, FieldOptions, SchemaConstructor, SchemaInputType, getFields, getFieldsWithPrivacy, getFieldsWithEditPrivacy, getStorageKey, ActionOperation, Action, EdgeAction, NoFields, FieldMap, Constraint, Index, EdgeIndex, ConstraintType, ForeignKeyInfo, requiredField, optionalField, UpdateOperation, TransformedUpdateOperation, SQLStatementOperation, EdgeUpdateOperation, TransformedEdgeUpdateOperation, getTransformedReadClause, getObjectLoaderProperties, GlobalSchema, DBExtension, ActionField, } from "./schema";
4
- export { Timestamps, Node, BaseEntSchema, BaseEntSchemaWithTZ, EntSchema, EntSchemaWithTZ, SchemaConfig, } from "./base_schema";
1
+ export type { Schema } from "./schema";
2
+ export { DBType, getFields, getFieldsWithPrivacy, getFieldsWithEditPrivacy, getStorageKey, ActionOperation, NoFields, ConstraintType, requiredField, optionalField, SQLStatementOperation, getTransformedReadClause, getObjectLoaderProperties, } from "./schema";
3
+ export { Timestamps, Node, BaseEntSchema, BaseEntSchemaWithTZ, EntSchema, EntSchemaWithTZ, } from "./base_schema";
4
+ export type { Action, ActionField, AssocEdge, AssocEdgeGroup, Constraint, DBExtension, Edge, EdgeAction, EdgeIndex, EdgeUpdateOperation, Field, FieldMap, FieldOptions, ForeignKeyInfo, GlobalSchema, Index, InverseAssocEdge, Pattern, SchemaConstructor, SchemaInputType, TransformedEdgeUpdateOperation, TransformedUpdateOperation, Type, UpdateOperation, } from "./schema";
5
+ export type { SchemaConfig } from "./base_schema";
5
6
  export * from "./field";
6
7
  export * from "./json_field";
7
8
  export * from "./struct_field";
@@ -35,7 +35,7 @@ type FieldOverride = Pick<FieldOptions, "nullable" | "storageKey" | "serverDefau
35
35
  export type FieldOverrideMap = {
36
36
  [key: string]: FieldOverride;
37
37
  };
38
- export default interface Schema {
38
+ export interface Schema {
39
39
  fields: FieldMap;
40
40
  fieldOverrides?: FieldOverrideMap;
41
41
  tableName?: string;
@@ -70,6 +70,7 @@ export interface AssocEdge {
70
70
  export interface EdgeAction {
71
71
  operation: ActionOperation;
72
72
  actionName?: string;
73
+ inputName?: string;
73
74
  hideFromGraphQL?: boolean;
74
75
  graphQLName?: string;
75
76
  actionOnlyFields?: ActionField[];
@@ -84,6 +85,7 @@ export interface InverseAssocEdge {
84
85
  export interface EdgeGroupAction {
85
86
  operation: ActionOperation.EdgeGroup;
86
87
  actionName?: string;
88
+ inputName?: string;
87
89
  hideFromGraphQL?: boolean;
88
90
  graphQLName?: string;
89
91
  actionOnlyFields?: ActionField[];