Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .agents/skills/cli-public/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
name: cli-public
description: CLI tool (csdk) for the public API — provides CRUD commands for 148 tables and 71 custom operations
description: CLI tool (csdk) for the public API — provides CRUD commands for 148 tables and 72 custom operations
---

# cli-public

<!-- @constructive-io/graphql-codegen - DO NOT EDIT -->

CLI tool (csdk) for the public API — provides CRUD commands for 148 tables and 71 custom operations
CLI tool (csdk) for the public API — provides CRUD commands for 148 tables and 72 custom operations

## Usage

Expand Down Expand Up @@ -252,7 +252,8 @@ See the `references/` directory for detailed per-entity API documentation:
- [provision-spatial-relation](references/provision-spatial-relation.md)
- [bootstrap-user](references/bootstrap-user.md)
- [set-field-order](references/set-field-order.md)
- [append-smart-tags](references/append-smart-tags.md)
- [append-field-smart-tags](references/append-field-smart-tags.md)
- [append-table-smart-tags](references/append-table-smart-tags.md)
- [provision-unique-constraint](references/provision-unique-constraint.md)
- [provision-full-text-search](references/provision-full-text-search.md)
- [provision-index](references/provision-index.md)
Expand Down
19 changes: 19 additions & 0 deletions .agents/skills/cli-public/references/append-field-smart-tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# appendFieldSmartTags

<!-- @constructive-io/graphql-codegen - DO NOT EDIT -->

Execute the appendFieldSmartTags mutation

## Usage

```bash
csdk append-field-smart-tags --input.clientMutationId <String> --input.pFieldId <UUID> --input.pTags <JSON>
```

## Examples

### Run appendFieldSmartTags

```bash
csdk append-field-smart-tags --input.clientMutationId <String> --input.pFieldId <UUID> --input.pTags <JSON>
```
19 changes: 19 additions & 0 deletions .agents/skills/cli-public/references/append-table-smart-tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# appendTableSmartTags

<!-- @constructive-io/graphql-codegen - DO NOT EDIT -->

Execute the appendTableSmartTags mutation

## Usage

```bash
csdk append-table-smart-tags --input.clientMutationId <String> --input.pTableId <UUID> --input.pTags <JSON>
```

## Examples

### Run appendTableSmartTags

```bash
csdk append-table-smart-tags --input.clientMutationId <String> --input.pTableId <UUID> --input.pTags <JSON>
```
7 changes: 4 additions & 3 deletions .agents/skills/hooks-public/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
name: hooks-public
description: React Query hooks for the public API — provides typed query and mutation hooks for 148 tables and 71 custom operations
description: React Query hooks for the public API — provides typed query and mutation hooks for 148 tables and 72 custom operations
---

# hooks-public

<!-- @constructive-io/graphql-codegen - DO NOT EDIT -->

React Query hooks for the public API — provides typed query and mutation hooks for 148 tables and 71 custom operations
React Query hooks for the public API — provides typed query and mutation hooks for 148 tables and 72 custom operations

## Usage

Expand Down Expand Up @@ -233,7 +233,8 @@ See the `references/` directory for detailed per-entity API documentation:
- [provision-spatial-relation](references/provision-spatial-relation.md)
- [bootstrap-user](references/bootstrap-user.md)
- [set-field-order](references/set-field-order.md)
- [append-smart-tags](references/append-smart-tags.md)
- [append-field-smart-tags](references/append-field-smart-tags.md)
- [append-table-smart-tags](references/append-table-smart-tags.md)
- [provision-unique-constraint](references/provision-unique-constraint.md)
- [provision-full-text-search](references/provision-full-text-search.md)
- [provision-index](references/provision-index.md)
Expand Down
20 changes: 20 additions & 0 deletions .agents/skills/hooks-public/references/append-field-smart-tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# appendFieldSmartTags

<!-- @constructive-io/graphql-codegen - DO NOT EDIT -->

React Query mutation hook for appendFieldSmartTags

## Usage

```typescript
const { mutate } = useAppendFieldSmartTagsMutation(); mutate({ input: { pFieldId: '<UUID>', pTags: '<JSON>' } });
```

## Examples

### Use useAppendFieldSmartTagsMutation

```typescript
const { mutate, isLoading } = useAppendFieldSmartTagsMutation();
mutate({ input: { pFieldId: '<UUID>', pTags: '<JSON>' } });
```
20 changes: 20 additions & 0 deletions .agents/skills/hooks-public/references/append-table-smart-tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# appendTableSmartTags

<!-- @constructive-io/graphql-codegen - DO NOT EDIT -->

React Query mutation hook for appendTableSmartTags

## Usage

```typescript
const { mutate } = useAppendTableSmartTagsMutation(); mutate({ input: { pTableId: '<UUID>', pTags: '<JSON>' } });
```

## Examples

### Use useAppendTableSmartTagsMutation

```typescript
const { mutate, isLoading } = useAppendTableSmartTagsMutation();
mutate({ input: { pTableId: '<UUID>', pTags: '<JSON>' } });
```
7 changes: 4 additions & 3 deletions .agents/skills/orm-public/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
name: orm-public
description: ORM client for the public API — provides typed CRUD operations for 148 tables and 71 custom operations
description: ORM client for the public API — provides typed CRUD operations for 148 tables and 72 custom operations
---

# orm-public

<!-- @constructive-io/graphql-codegen - DO NOT EDIT -->

ORM client for the public API — provides typed CRUD operations for 148 tables and 71 custom operations
ORM client for the public API — provides typed CRUD operations for 148 tables and 72 custom operations

## Usage

Expand Down Expand Up @@ -233,7 +233,8 @@ See the `references/` directory for detailed per-entity API documentation:
- [provision-spatial-relation](references/provision-spatial-relation.md)
- [bootstrap-user](references/bootstrap-user.md)
- [set-field-order](references/set-field-order.md)
- [append-smart-tags](references/append-smart-tags.md)
- [append-field-smart-tags](references/append-field-smart-tags.md)
- [append-table-smart-tags](references/append-table-smart-tags.md)
- [provision-unique-constraint](references/provision-unique-constraint.md)
- [provision-full-text-search](references/provision-full-text-search.md)
- [provision-index](references/provision-index.md)
Expand Down
19 changes: 19 additions & 0 deletions .agents/skills/orm-public/references/append-field-smart-tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# appendFieldSmartTags

<!-- @constructive-io/graphql-codegen - DO NOT EDIT -->

Execute the appendFieldSmartTags mutation

## Usage

```typescript
db.mutation.appendFieldSmartTags({ input: { pFieldId: '<UUID>', pTags: '<JSON>' } }).execute()
```

## Examples

### Run appendFieldSmartTags

```typescript
const result = await db.mutation.appendFieldSmartTags({ input: { pFieldId: '<UUID>', pTags: '<JSON>' } }).execute();
```
19 changes: 19 additions & 0 deletions .agents/skills/orm-public/references/append-table-smart-tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# appendTableSmartTags

<!-- @constructive-io/graphql-codegen - DO NOT EDIT -->

Execute the appendTableSmartTags mutation

## Usage

```typescript
db.mutation.appendTableSmartTags({ input: { pTableId: '<UUID>', pTags: '<JSON>' } }).execute()
```

## Examples

### Run appendTableSmartTags

```typescript
const result = await db.mutation.appendTableSmartTags({ input: { pTableId: '<UUID>', pTags: '<JSON>' } }).execute();
```
83 changes: 83 additions & 0 deletions sdk/constructive-cli/src/admin/orm/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,35 @@ import type {
} from '@constructive-io/graphql-query/runtime';
import { createFetch } from '@constructive-io/graphql-query/runtime';

import type {
ConnectionState,
ConnectionStateListener,
RealtimeConfig,
SubscribeOptions,
SubscriptionEvent,
SubscriptionFieldMeta,
Unsubscribe,
} from './realtime';
import { RealtimeManager } from './realtime';

export type {
GraphQLAdapter,
GraphQLError,
QueryResult,
} from '@constructive-io/graphql-query/runtime';

export type {
ConnectionState,
ConnectionStateListener,
RealtimeConfig,
SubscribeOptions,
SubscriptionEvent,
SubscriptionFieldMeta,
SubscriptionOperation,
Unsubscribe,
} from './realtime';
export { RealtimeManager } from './realtime';

/**
* Default adapter that uses fetch for HTTP requests.
*
Expand Down Expand Up @@ -107,6 +130,12 @@ export interface OrmClientConfig {
fetch?: typeof globalThis.fetch;
/** Custom adapter for GraphQL execution (overrides endpoint/headers/fetch) */
adapter?: GraphQLAdapter;
/**
* Optional realtime (WebSocket) configuration.
* When provided, enables subscription methods on models.
* The WebSocket connection is created lazily on first subscribe().
*/
realtime?: RealtimeConfig;
}

/**
Expand All @@ -125,6 +154,7 @@ export class GraphQLRequestError extends Error {

export class OrmClient {
private adapter: GraphQLAdapter;
private realtimeManager?: RealtimeManager;

constructor(config: OrmClientConfig) {
if (config.adapter) {
Expand All @@ -134,12 +164,39 @@ export class OrmClient {
} else {
throw new Error('OrmClientConfig requires either an endpoint or a custom adapter');
}

if (config.realtime) {
this.realtimeManager = new RealtimeManager(config.realtime);
}
}

async execute<T>(document: string, variables?: Record<string, unknown>): Promise<QueryResult<T>> {
return this.adapter.execute<T>(document, variables);
}

/**
* Subscribe to a GraphQL subscription operation.
* Used by generated model subscribe() methods.
* @throws Error if realtime is not configured
*/
subscribe<T>(
meta: SubscriptionFieldMeta,
document: string,
variables: Record<string, unknown>,
options: {
onEvent: (event: SubscriptionEvent<T>) => void;
onError?: (error: Error) => void;
onComplete?: () => void;
}
): Unsubscribe {
if (!this.realtimeManager) {
throw new Error(
'Realtime not configured. Pass a `realtime` option to createClient() to enable subscriptions.'
);
}
return this.realtimeManager.subscribe<T>(meta, document, variables, options);
}

/**
* Set headers for requests.
* Only works if the adapter supports headers.
Expand All @@ -157,4 +214,30 @@ export class OrmClient {
getEndpoint(): string {
return this.adapter.getEndpoint?.() ?? '';
}

/** Get current WebSocket connection state */
getConnectionState(): ConnectionState {
return this.realtimeManager?.getConnectionState() ?? 'disconnected';
}

/** Register a listener for WebSocket connection state changes */
onConnectionStateChange(listener: ConnectionStateListener): Unsubscribe {
if (!this.realtimeManager) return () => {};
return this.realtimeManager.onConnectionStateChange(listener);
}

/** Number of active subscriptions */
getActiveSubscriptionCount(): number {
return this.realtimeManager?.getActiveSubscriptionCount() ?? 0;
}

/** Whether realtime is configured */
get isRealtimeEnabled(): boolean {
return this.realtimeManager !== undefined;
}

/** Dispose the realtime manager (close WebSocket) */
dispose(): void {
this.realtimeManager?.dispose();
}
}
Loading
Loading