@syncular/server 0.32.0 → 0.33.0

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/src/seed.ts CHANGED
@@ -24,6 +24,7 @@ import { SyncError } from './errors';
24
24
  import type { SyncularServerEvent, SyncularServerEvents } from './events';
25
25
  import { composeEvents } from './events-ring';
26
26
  import { handleSyncRequest } from './handler';
27
+ import { renderScopeValue } from './scopes';
27
28
 
28
29
  /** One app-shaped seed mutation — the same vocabulary as client mutations. */
29
30
  export type SeedMutation =
@@ -171,11 +172,11 @@ export async function seedMutations(
171
172
  (column) => (byColumn.get(column.name) ?? null) as RowValue,
172
173
  );
173
174
  const pkIndex = table.columns.findIndex((c) => c.name === table.primaryKey);
174
- const rowId = values[pkIndex];
175
- if (typeof rowId !== 'string' || rowId.length === 0) {
175
+ const rowId = renderScopeValue(values[pkIndex]);
176
+ if (rowId === undefined) {
176
177
  throw new SyncError(
177
178
  'sync.invalid_request',
178
- `seedMutations: table ${table.name}: upsert requires a non-empty string primary key`,
179
+ `seedMutations: table ${table.name}: upsert requires a non-empty primary key`,
179
180
  );
180
181
  }
181
182
  return {