@microsoft/rayfin-connector-fabric-graphql 1.34.0-alpha.1221 → 1.34.0-alpha.1270

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.
Files changed (2) hide show
  1. package/dist/types.d.ts +69 -36
  2. package/package.json +3 -3
package/dist/types.d.ts CHANGED
@@ -1,59 +1,92 @@
1
- import { METHODS_FOR_CRUD_OPERATION, type ConnectorMarker, type CrudOperation } from '@microsoft/rayfin-connectors';
2
- import type { EntitySchema, GraphQLEntityClient } from '@microsoft/rayfin-data';
3
- /**
4
- * Re-exported from `@microsoft/rayfin-connectors` so the runtime
5
- * allow-list (`ConnectorConfig.operations`), the CLI validators in
6
- * `@microsoft/rayfin-tools-common`, and this type marker all reference
7
- * the same union and cannot drift.
8
- */
1
+ import { METHODS_FOR_CRUD_OPERATION, type ConnectorConfig, type ConnectorMarker, type ConnectorEntityClient, type ConnectorType, type CrudOperation, type WhereUniqueOf } from '@microsoft/rayfin-connectors';
2
+ import type { EntitySchema } from '@microsoft/rayfin-data';
3
+ /** Re-export of the shared CRUD-operation union from `@microsoft/rayfin-connectors`. */
9
4
  export type { CrudOperation };
10
5
  /**
11
- * The subset of `GraphQLEntityClient` method names associated with each
12
- * CRUD operation. Derived from the shared runtime constant
13
- * `METHODS_FOR_CRUD_OPERATION` in `@microsoft/rayfin-connectors`, so the
14
- * compile-time gate and runtime gate use the exact same mapping.
6
+ * The {@link ConnectorEntityClient} method names associated with a CRUD
7
+ * operation, read from the runtime constant `METHODS_FOR_CRUD_OPERATION`.
15
8
  */
16
9
  type MethodsFor<TOp extends CrudOperation> = (typeof METHODS_FOR_CRUD_OPERATION)[TOp][number];
10
+ /** Entity-client method names that require a declared primary key. */
11
+ type ByKeyMethod = 'findByKey' | 'update' | 'delete';
17
12
  /**
18
- * Narrows `GraphQLEntityClient<TSchema, TEntity>` to only the methods
19
- * permitted by `TOps`. Disallowed methods become inaccessible at
20
- * compile time — calling `connector.Entity.update(...)` on a `'read'`
21
- * connector is a `Property 'update' does not exist` error.
13
+ * `true` when entity `TEntity` in `TSchema` declares a usable primary key,
14
+ * `false` when {@link WhereUniqueOf} resolves to `never` (`primaryKey: []`,
15
+ * `primaryKey` omitted, or no `Source` phantom).
16
+ */
17
+ type HasPrimaryKey<TSchema extends EntitySchema, TEntity extends keyof TSchema> = [WhereUniqueOf<TSchema[TEntity]>] extends [never] ? false : true;
18
+ /**
19
+ * The entity client for one schema entry, restricted to the methods permitted
20
+ * by two gates:
21
+ * - **CRUD ops** (`TOps`) — keeps only the methods mapped to the connector's
22
+ * declared operations via `METHODS_FOR_CRUD_OPERATION`.
23
+ * - **Primary key** — when the entry declares no key, {@link ByKeyMethod}
24
+ * (`findByKey`/`update`/`delete`) is removed from the type; `create`
25
+ * and the key-agnostic reads remain.
26
+ *
27
+ * `TDialect` is the connector's type literal; it flows into
28
+ * `ConnectorEntityClient` so the mutation methods return `DbOperationResult`
29
+ * for connectors without read-after-write (Fabric Warehouse) and the entity
30
+ * row otherwise.
22
31
  */
23
- export type RestrictedEntityClient<TSchema extends EntitySchema, TEntity extends keyof TSchema & string, TOps extends CrudOperation> = Pick<GraphQLEntityClient<TSchema, TEntity>, MethodsFor<TOps> & keyof GraphQLEntityClient<TSchema, TEntity>>;
32
+ export type RestrictedEntityClient<TSchema extends EntitySchema, TEntity extends keyof TSchema & string, TOps extends CrudOperation, TDialect extends ConnectorType = ConnectorType> = Pick<ConnectorEntityClient<TSchema, TEntity, TDialect>, HasPrimaryKey<TSchema, TEntity> extends true ? MethodsFor<TOps> : Exclude<MethodsFor<TOps>, ByKeyMethod>>;
24
33
  /**
25
34
  * Type-level entity API for a Category A connector: one
26
- * `RestrictedEntityClient` per entity in the connector's schema, gated
27
- * by `TOps`. Mirrors the shape of `TypedDataClients<TSchema>` from
28
- * `@microsoft/rayfin-data` but with CRUD gating layered on.
35
+ * {@link RestrictedEntityClient} per entity in the schema, gated by `TOps`
36
+ * and typed for the connector's `TDialect`.
29
37
  */
30
- export type RestrictedDataApi<TSchema extends EntitySchema, TOps extends CrudOperation = CrudOperation> = {
31
- [K in keyof TSchema & string]: RestrictedEntityClient<TSchema, K, TOps>;
38
+ export type RestrictedDataApi<TSchema extends EntitySchema, TOps extends CrudOperation = CrudOperation, TDialect extends ConnectorType = ConnectorType> = {
39
+ [K in keyof TSchema & string]: RestrictedEntityClient<TSchema, K, TOps, TDialect>;
32
40
  };
33
41
  /**
34
- * Phantom marker for a Category A (GraphQL-backed) connector instance.
42
+ * The CRUD-operation union a connector permits, read from its
43
+ * {@link ConnectorConfig}. `operations` is a literal tuple (the CLI emits the
44
+ * config `as const satisfies ConnectorConfig`), so `[number]` recovers the
45
+ * exact verbs. `NonNullable` drops the `| undefined` the optional `operations?`
46
+ * adds, so a widened `ConnectorConfig` still yields the full {@link CrudOperation}
47
+ * union.
48
+ */
49
+ type OpsOf<TConfig extends ConnectorConfig> = NonNullable<TConfig['operations']>[number];
50
+ /**
51
+ * Phantom marker for a Category A (GraphQL-backed) connector instance. The CLI
52
+ * emits a per-connector `schema.ts` declaring e.g.
53
+ * `type SalesDbSchema = GraphQLBackedConnector<{ Product: typeof Product }, typeof connectorConfig>;`,
54
+ * and the `client.connectors.<name>` proxy resolves to a
55
+ * {@link RestrictedDataApi} exposing only the permitted CRUD methods.
35
56
  *
36
- * Builders never construct this directly. The CLI generates a
37
- * `schema.ts` per connector that declares e.g.
38
- * `type SalesDbSchema = GraphQLBackedConnector<{ Product: typeof Product }, 'read'>;`
39
- * and the typed `client.connectors.salesDb` proxy resolves to a
40
- * `RestrictedDataApi<...>` whose entity clients only expose the
41
- * permitted CRUD methods.
57
+ * The second parameter is the connector's own `connectorConfig` type (via
58
+ * `typeof connectorConfig`), so the permitted operations ({@link OpsOf}) and
59
+ * the dialect (`TConfig['connector']`) are both derived from one source. The
60
+ * dialect drives the mutation return type: `DbOperationResult` for connectors
61
+ * without read-after-write (Fabric Warehouse), the entity row otherwise. For
62
+ * the literals to survive, declare the config with an
63
+ * `as const satisfies ConnectorConfig` clause (a `: ConnectorConfig`
64
+ * annotation widens `connector` and `operations`).
42
65
  *
43
- * Both type parameters are phantom — the fields exist only at the
44
- * type level so the mapped type in `@microsoft/rayfin-connectors`
45
- * can infer them via `infer S`, `infer O`.
66
+ * Both parameters are phantom (type-level only) so the mapped type in
67
+ * `@microsoft/rayfin-connectors` can infer them.
68
+ *
69
+ * Key each entity name to its **constructor** (`typeof Product`), not its
70
+ * instance type. The constructor carries the `RayfinPrimaryKey` phantom from
71
+ * `Source({ primaryKey })` used to derive the composite/custom `where` shape;
72
+ * a bare instance entry has no phantom and is therefore treated as keyless
73
+ * (no by-key methods).
46
74
  *
47
75
  * @example
48
76
  * ```ts
49
- * type LakehouseSchema = GraphQLBackedConnector<{ Product: typeof Product }, 'read'>;
77
+ * const connectorConfig = {
78
+ * connector: 'fabric-warehouse',
79
+ * operations: ['read', 'create', 'update', 'delete'],
80
+ * } as const satisfies ConnectorConfig;
81
+ *
50
82
  * type SalesDbSchema = GraphQLBackedConnector<
51
- * { Product: typeof Product; Customer: typeof Customer }
83
+ * { Product: typeof Product; Customer: typeof Customer },
84
+ * typeof connectorConfig
52
85
  * >;
53
86
  * ```
54
87
  */
55
- export interface GraphQLBackedConnector<TSchema extends EntitySchema = EntitySchema, TOps extends CrudOperation = CrudOperation> extends ConnectorMarker<RestrictedDataApi<TSchema, TOps>> {
88
+ export interface GraphQLBackedConnector<TSchema extends EntitySchema = EntitySchema, TConfig extends ConnectorConfig = ConnectorConfig> extends ConnectorMarker<RestrictedDataApi<TSchema, OpsOf<TConfig>, TConfig['connector']>> {
56
89
  readonly __schema?: TSchema;
57
- readonly __ops?: TOps;
90
+ readonly __config?: TConfig;
58
91
  }
59
92
  //# sourceMappingURL=types.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/rayfin-connector-fabric-graphql",
3
- "version": "1.34.0-alpha.1221",
3
+ "version": "1.34.0-alpha.1270",
4
4
  "description": "Experimental Cat A GraphQL-backed connector types for the Rayfin SDK. Provides the entity-oriented marker (GraphQLBackedConnector) and CRUD operation gating used by the typed client.connectors.<name>.<Entity>.select(...).execute() surface.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,8 +19,8 @@
19
19
  "rimraf": "~6.0.1"
20
20
  },
21
21
  "dependencies": {
22
- "@microsoft/rayfin-data": "1.34.0-alpha.1221",
23
- "@microsoft/rayfin-connectors": "1.34.0-alpha.1221"
22
+ "@microsoft/rayfin-connectors": "1.34.0-alpha.1270",
23
+ "@microsoft/rayfin-data": "1.34.0-alpha.1270"
24
24
  },
25
25
  "publishConfig": {
26
26
  "registry": "https://npm.pkg.github.com",