workos 0.12.0-beta.1 → 0.12.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.
Files changed (96) hide show
  1. package/README.md +6 -4
  2. package/dist/bin.js +4 -2
  3. package/dist/bin.js.map +1 -1
  4. package/dist/commands/debug.js +0 -1
  5. package/dist/commands/debug.js.map +1 -1
  6. package/dist/commands/login.js +0 -4
  7. package/dist/commands/login.js.map +1 -1
  8. package/dist/emulate/core/id.d.ts +16 -1
  9. package/dist/emulate/core/id.js +16 -1
  10. package/dist/emulate/core/id.js.map +1 -1
  11. package/dist/emulate/core/index.d.ts +1 -1
  12. package/dist/emulate/core/index.js +1 -1
  13. package/dist/emulate/core/index.js.map +1 -1
  14. package/dist/emulate/core/middleware/auth.d.ts +1 -4
  15. package/dist/emulate/core/middleware/auth.js +7 -18
  16. package/dist/emulate/core/middleware/auth.js.map +1 -1
  17. package/dist/emulate/core/pagination.d.ts +6 -0
  18. package/dist/emulate/core/pagination.js +9 -1
  19. package/dist/emulate/core/pagination.js.map +1 -1
  20. package/dist/emulate/core/server.js +20 -46
  21. package/dist/emulate/core/server.js.map +1 -1
  22. package/dist/emulate/core/store.d.ts +2 -0
  23. package/dist/emulate/core/store.js +22 -1
  24. package/dist/emulate/core/store.js.map +1 -1
  25. package/dist/emulate/workos/constants.d.ts +56 -0
  26. package/dist/emulate/workos/constants.js +56 -0
  27. package/dist/emulate/workos/constants.js.map +1 -0
  28. package/dist/emulate/workos/entities.js.map +1 -1
  29. package/dist/emulate/workos/event-bus.d.ts +6 -1
  30. package/dist/emulate/workos/event-bus.js +33 -8
  31. package/dist/emulate/workos/event-bus.js.map +1 -1
  32. package/dist/emulate/workos/helpers.d.ts +17 -8
  33. package/dist/emulate/workos/helpers.js +61 -368
  34. package/dist/emulate/workos/helpers.js.map +1 -1
  35. package/dist/emulate/workos/index.js +42 -39
  36. package/dist/emulate/workos/index.js.map +1 -1
  37. package/dist/emulate/workos/role-helpers.d.ts +21 -0
  38. package/dist/emulate/workos/role-helpers.js +130 -0
  39. package/dist/emulate/workos/role-helpers.js.map +1 -0
  40. package/dist/emulate/workos/routes/api-keys.js +5 -8
  41. package/dist/emulate/workos/routes/api-keys.js.map +1 -1
  42. package/dist/emulate/workos/routes/audit-logs.js +6 -9
  43. package/dist/emulate/workos/routes/audit-logs.js.map +1 -1
  44. package/dist/emulate/workos/routes/auth.js +7 -6
  45. package/dist/emulate/workos/routes/auth.js.map +1 -1
  46. package/dist/emulate/workos/routes/authorization-checks.js +5 -17
  47. package/dist/emulate/workos/routes/authorization-checks.js.map +1 -1
  48. package/dist/emulate/workos/routes/authorization-org-roles.js +29 -171
  49. package/dist/emulate/workos/routes/authorization-org-roles.js.map +1 -1
  50. package/dist/emulate/workos/routes/authorization-permissions.js +5 -16
  51. package/dist/emulate/workos/routes/authorization-permissions.js.map +1 -1
  52. package/dist/emulate/workos/routes/authorization-resources.js +4 -15
  53. package/dist/emulate/workos/routes/authorization-resources.js.map +1 -1
  54. package/dist/emulate/workos/routes/authorization-roles.d.ts +1 -1
  55. package/dist/emulate/workos/routes/authorization-roles.js +9 -132
  56. package/dist/emulate/workos/routes/authorization-roles.js.map +1 -1
  57. package/dist/emulate/workos/routes/config.js +3 -2
  58. package/dist/emulate/workos/routes/config.js.map +1 -1
  59. package/dist/emulate/workos/routes/connect.js +3 -7
  60. package/dist/emulate/workos/routes/connect.js.map +1 -1
  61. package/dist/emulate/workos/routes/connections.js +3 -7
  62. package/dist/emulate/workos/routes/connections.js.map +1 -1
  63. package/dist/emulate/workos/routes/directories.js +7 -23
  64. package/dist/emulate/workos/routes/directories.js.map +1 -1
  65. package/dist/emulate/workos/routes/events.js +3 -6
  66. package/dist/emulate/workos/routes/events.js.map +1 -1
  67. package/dist/emulate/workos/routes/feature-flags.js +20 -48
  68. package/dist/emulate/workos/routes/feature-flags.js.map +1 -1
  69. package/dist/emulate/workos/routes/invitations.js +10 -13
  70. package/dist/emulate/workos/routes/invitations.js.map +1 -1
  71. package/dist/emulate/workos/routes/memberships.js +3 -7
  72. package/dist/emulate/workos/routes/memberships.js.map +1 -1
  73. package/dist/emulate/workos/routes/organizations.js +13 -15
  74. package/dist/emulate/workos/routes/organizations.js.map +1 -1
  75. package/dist/emulate/workos/routes/pipes.js +3 -7
  76. package/dist/emulate/workos/routes/pipes.js.map +1 -1
  77. package/dist/emulate/workos/routes/radar.js +3 -7
  78. package/dist/emulate/workos/routes/radar.js.map +1 -1
  79. package/dist/emulate/workos/routes/sso.js +7 -6
  80. package/dist/emulate/workos/routes/sso.js.map +1 -1
  81. package/dist/emulate/workos/routes/users.js +3 -7
  82. package/dist/emulate/workos/routes/users.js.map +1 -1
  83. package/dist/emulate/workos/routes/webhook-endpoints.js +3 -7
  84. package/dist/emulate/workos/routes/webhook-endpoints.js.map +1 -1
  85. package/dist/emulate/workos/store.js +68 -59
  86. package/dist/emulate/workos/store.js.map +1 -1
  87. package/dist/lib/run-with-core.js +0 -3
  88. package/dist/lib/run-with-core.js.map +1 -1
  89. package/dist/lib/settings.js +1 -1
  90. package/dist/lib/settings.js.map +1 -1
  91. package/dist/utils/help-json.js +1 -23
  92. package/dist/utils/help-json.js.map +1 -1
  93. package/dist/utils/register-subcommand.d.ts +5 -2
  94. package/dist/utils/register-subcommand.js +16 -19
  95. package/dist/utils/register-subcommand.js.map +1 -1
  96. package/package.json +2 -2
@@ -26,6 +26,7 @@ export declare class Collection<T extends Entity> {
26
26
  findOneBy(field: keyof T, value: string | number): T | undefined;
27
27
  update(id: string, data: Partial<T>): T | undefined;
28
28
  delete(id: string): boolean;
29
+ deleteBy(field: keyof T, value: string | number): number;
29
30
  setHooks(hooks: CollectionHooks<T>): void;
30
31
  all(): T[];
31
32
  list(options?: CursorPaginationOptions<T>): CursorPaginatedResult<T>;
@@ -38,5 +39,6 @@ export declare class Store {
38
39
  collection<T extends Entity>(name: string, prefix: string, indexFields?: (keyof T)[]): Collection<T>;
39
40
  getData<V>(key: string): V | undefined;
40
41
  setData<V>(key: string, value: V): void;
42
+ deleteDataByPrefix(prefix: string): number;
41
43
  reset(): void;
42
44
  }
@@ -93,6 +93,12 @@ export class Collection {
93
93
  this.removeFromIndex(existing);
94
94
  return this.items.delete(id);
95
95
  }
96
+ deleteBy(field, value) {
97
+ const items = this.findBy(field, value);
98
+ for (const item of items)
99
+ this.delete(item.id);
100
+ return items.length;
101
+ }
96
102
  setHooks(hooks) {
97
103
  this.hooks = hooks;
98
104
  }
@@ -105,7 +111,12 @@ export class Collection {
105
111
  count(filter) {
106
112
  if (!filter)
107
113
  return this.items.size;
108
- return this.all().filter(filter).length;
114
+ let n = 0;
115
+ for (const item of this.items.values()) {
116
+ if (filter(item))
117
+ n++;
118
+ }
119
+ return n;
109
120
  }
110
121
  clear() {
111
122
  this.items.clear();
@@ -138,6 +149,16 @@ export class Store {
138
149
  setData(key, value) {
139
150
  this._data.set(key, value);
140
151
  }
152
+ deleteDataByPrefix(prefix) {
153
+ let count = 0;
154
+ for (const key of this._data.keys()) {
155
+ if (key.startsWith(prefix)) {
156
+ this._data.delete(key);
157
+ count++;
158
+ }
159
+ }
160
+ return count;
161
+ }
141
162
  reset() {
142
163
  for (const collection of this.collections.values()) {
143
164
  collection.clear();
@@ -1 +1 @@
1
- {"version":3,"file":"store.js","sourceRoot":"","sources":["../../../src/emulate/core/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,cAAc,EAAyE,MAAM,iBAAiB,CAAC;AAiBxH,MAAM,OAAO,UAAU;IAOX;IACA;IAPF,KAAK,GAAG,IAAI,GAAG,EAAa,CAAC;IAC7B,OAAO,GAAG,IAAI,GAAG,EAAoC,CAAC;IACtD,KAAK,GAAuB,EAAE,CAAC;IAC9B,UAAU,CAAW;IAE9B,YACU,MAAc,EACd,cAA2B,EAAE;QAD7B,WAAM,GAAN,MAAM,CAAQ;QACd,gBAAW,GAAX,WAAW,CAAkB;QAErC,I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C,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC9G,MAAM,IAAI,KAAK,CACb,eAAe,IAAI,kCAAkC,QAAQ,CAAC,UAAU,6BAA6B,SAAS,GAAG,CAClH,CAAC;gBACJ,CAAC;YACH,CAAC;YACD,OAAO,QAAyB,CAAC;QACnC,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,UAAU,CAAI,MAAM,EAAE,WAAW,CAAC,CAAC;QACnD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAChC,OAAO,GAAG,CAAC;IACb,CAAC;IAED,OAAO,CAAI,GAAW;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAkB,CAAC;IAC9C,CAAC;IAED,OAAO,CAAI,GAAW,EAAE,KAAQ;QAC9B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK;QACH,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC;YACnD,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF","sourcesContent":["import { generateId } from './id.js';\nimport { cursorPaginate, type Entity, type CursorPaginationOptions, type CursorPaginatedResult } from './pagination.js';\n\nexport type { Entity };\n\nexport type InsertInput<T extends Entity> = Omit<T, 'id' | 'created_at' | 'updated_at'> & {\n id?: string;\n};\n\nexport type FilterFn<T> = (item: T) => boolean;\nexport type SortFn<T> = (a: T, b: T) => number;\n\nexport interface CollectionHooks<T extends Entity> {\n onInsert?: (item: T) => void;\n onUpdate?: (item: T) => void;\n onDelete?: (item: T) => void;\n}\n\nexport class Collection<T extends Entity> {\n private items = new Map<string, T>();\n private indexes = new Map<string, Map<string, Set<string>>>();\n private hooks: CollectionHooks<T> = {};\n readonly fieldNames: string[];\n\n constructor(\n private prefix: string,\n private indexFields: (keyof T)[] = [],\n ) {\n this.fieldNames = indexFields.map(String).sort();\n for (const field of indexFields) {\n this.indexes.set(String(field), new Map());\n }\n }\n\n private addToIndex(item: T): void {\n for (const field of this.indexFields) {\n const value = item[field];\n if (value === undefined || value === null) continue;\n const indexMap = this.indexes.get(String(field))!;\n const key = String(value);\n if (!indexMap.has(key)) {\n indexMap.set(key, new Set());\n }\n indexMap.get(key)!.add(item.id);\n }\n }\n\n private removeFromIndex(item: T): void {\n for (const field of this.indexFields) {\n const value = item[field];\n if (value === undefined || value === null) continue;\n const indexMap = this.indexes.get(String(field))!;\n const key = String(value);\n indexMap.get(key)?.delete(item.id);\n }\n }\n\n insert(data: InsertInput<T>): T {\n const now = new Date().toISOString();\n const id = data.id ?? generateId(this.prefix);\n const item = {\n ...data,\n id,\n created_at: now,\n updated_at: now,\n } as unknown as T;\n this.items.set(id, item);\n this.addToIndex(item);\n this.hooks.onInsert?.(item);\n return item;\n }\n\n get(id: string): T | undefined {\n return this.items.get(id);\n }\n\n findBy(field: keyof T, value: string | number): T[] {\n if (this.indexes.has(String(field))) {\n const ids = this.indexes.get(String(field))!.get(String(value));\n if (!ids) return [];\n return Array.from(ids)\n .map((id) => this.items.get(id)!)\n .filter(Boolean);\n }\n return this.all().filter((item) => item[field] === value);\n }\n\n findOneBy(field: keyof T, value: string | number): T | undefined {\n return this.findBy(field, value)[0];\n }\n\n update(id: string, data: Partial<T>): T | undefined {\n const existing = this.items.get(id);\n if (!existing) return undefined;\n this.removeFromIndex(existing);\n const updated = {\n ...existing,\n ...data,\n id,\n updated_at: new Date().toISOString(),\n } as T;\n this.items.set(id, updated);\n this.addToIndex(updated);\n this.hooks.onUpdate?.(updated);\n return updated;\n }\n\n delete(id: string): boolean {\n const existing = this.items.get(id);\n if (!existing) return false;\n this.hooks.onDelete?.(existing);\n this.removeFromIndex(existing);\n return this.items.delete(id);\n }\n\n setHooks(hooks: CollectionHooks<T>): void {\n this.hooks = hooks;\n }\n\n all(): T[] {\n return Array.from(this.items.values());\n }\n\n list(options: CursorPaginationOptions<T> = {}): CursorPaginatedResult<T> {\n return cursorPaginate(this.all(), options);\n }\n\n count(filter?: FilterFn<T>): number {\n if (!filter) return this.items.size;\n return this.all().filter(filter).length;\n }\n\n clear(): void {\n this.items.clear();\n for (const indexMap of this.indexes.values()) {\n indexMap.clear();\n }\n }\n}\n\nexport class Store {\n private collections = new Map<string, Collection<any>>();\n private _data = new Map<string, unknown>();\n\n collection<T extends Entity>(name: string, prefix: string, indexFields: (keyof T)[] = []): Collection<T> {\n const existing = this.collections.get(name);\n if (existing) {\n if (indexFields.length > 0) {\n const requested = indexFields.map(String).sort();\n if (existing.fieldNames.length !== requested.length || existing.fieldNames.some((f, i) => f !== requested[i])) {\n throw new Error(\n `Collection \"${name}\" already exists with indexes [${existing.fieldNames}] but was requested with [${requested}]`,\n );\n }\n }\n return existing as Collection<T>;\n }\n const col = new Collection<T>(prefix, indexFields);\n this.collections.set(name, col);\n return col;\n }\n\n getData<V>(key: string): V | undefined {\n return this._data.get(key) as V | undefined;\n }\n\n setData<V>(key: string, value: V): void {\n this._data.set(key, value);\n }\n\n reset(): void {\n for (const collection of this.collections.values()) {\n collection.clear();\n }\n this._data.clear();\n }\n}\n"]}
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../../../src/emulate/core/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,cAAc,EAAyE,MAAM,iBAAiB,CAAC;AAiBxH,MAAM,OAAO,UAAU;IAOX;IACA;IAPF,KAAK,GAAG,IAAI,GAAG,EAAa,CAAC;IAC7B,OAAO,GAAG,IAAI,GAAG,EAAoC,CAAC;IACtD,KAAK,GAAuB,EAAE,CAAC;IAC9B,UAAU,CAAW;IAE9B,YACU,MAAc,EAC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AI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;YACpC,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC3B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBACvB,KAAK,EAAE,CAAC;YACV,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK;QACH,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC;YACnD,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF","sourcesContent":["import { generateId } from './id.js';\nimport { cursorPaginate, type Entity, type CursorPaginationOptions, type CursorPaginatedResult } from './pagination.js';\n\nexport type { Entity };\n\nexport type InsertInput<T extends Entity> = Omit<T, 'id' | 'created_at' | 'updated_at'> & {\n id?: string;\n};\n\nexport type FilterFn<T> = (item: T) => boolean;\nexport type SortFn<T> = (a: T, b: T) => number;\n\nexport interface CollectionHooks<T extends Entity> {\n onInsert?: (item: T) => void;\n onUpdate?: (item: T) => void;\n onDelete?: (item: T) => void;\n}\n\nexport class Collection<T extends Entity> {\n private items = new Map<string, T>();\n private indexes = new Map<string, Map<string, Set<string>>>();\n private hooks: CollectionHooks<T> = {};\n readonly fieldNames: string[];\n\n constructor(\n private prefix: string,\n private indexFields: (keyof T)[] = [],\n ) {\n this.fieldNames = indexFields.map(String).sort();\n for (const field of indexFields) {\n this.indexes.set(String(field), new Map());\n }\n }\n\n private addToIndex(item: T): void {\n for (const field of this.indexFields) {\n const value = item[field];\n if (value === undefined || value === null) continue;\n const indexMap = this.indexes.get(String(field))!;\n const key = String(value);\n if (!indexMap.has(key)) {\n indexMap.set(key, new Set());\n }\n indexMap.get(key)!.add(item.id);\n }\n }\n\n private removeFromIndex(item: T): void {\n for (const field of this.indexFields) {\n const value = item[field];\n if (value === undefined || value === null) continue;\n const indexMap = this.indexes.get(String(field))!;\n const key = String(value);\n indexMap.get(key)?.delete(item.id);\n }\n }\n\n insert(data: InsertInput<T>): T {\n const now = new Date().toISOString();\n const id = data.id ?? generateId(this.prefix);\n const item = {\n ...data,\n id,\n created_at: now,\n updated_at: now,\n } as unknown as T;\n this.items.set(id, item);\n this.addToIndex(item);\n this.hooks.onInsert?.(item);\n return item;\n }\n\n get(id: string): T | undefined {\n return this.items.get(id);\n }\n\n findBy(field: keyof T, value: string | number): T[] {\n if (this.indexes.has(String(field))) {\n const ids = this.indexes.get(String(field))!.get(String(value));\n if (!ids) return [];\n return Array.from(ids)\n .map((id) => this.items.get(id)!)\n .filter(Boolean);\n }\n return this.all().filter((item) => item[field] === value);\n }\n\n findOneBy(field: keyof T, value: string | number): T | undefined {\n return this.findBy(field, value)[0];\n }\n\n update(id: string, data: Partial<T>): T | undefined {\n const existing = this.items.get(id);\n if (!existing) return undefined;\n this.removeFromIndex(existing);\n const updated = {\n ...existing,\n ...data,\n id,\n updated_at: new Date().toISOString(),\n } as T;\n this.items.set(id, updated);\n this.addToIndex(updated);\n this.hooks.onUpdate?.(updated);\n return updated;\n }\n\n delete(id: string): boolean {\n const existing = this.items.get(id);\n if (!existing) return false;\n this.hooks.onDelete?.(existing);\n this.removeFromIndex(existing);\n return this.items.delete(id);\n }\n\n deleteBy(field: keyof T, value: string | number): number {\n const items = this.findBy(field, value);\n for (const item of items) this.delete(item.id);\n return items.length;\n }\n\n setHooks(hooks: CollectionHooks<T>): void {\n this.hooks = hooks;\n }\n\n all(): T[] {\n return Array.from(this.items.values());\n }\n\n list(options: CursorPaginationOptions<T> = {}): CursorPaginatedResult<T> {\n return cursorPaginate(this.all(), options);\n }\n\n count(filter?: FilterFn<T>): number {\n if (!filter) return this.items.size;\n let n = 0;\n for (const item of this.items.values()) {\n if (filter(item)) n++;\n }\n return n;\n }\n\n clear(): void {\n this.items.clear();\n for (const indexMap of this.indexes.values()) {\n indexMap.clear();\n }\n }\n}\n\nexport class Store {\n private collections = new Map<string, Collection<any>>();\n private _data = new Map<string, unknown>();\n\n collection<T extends Entity>(name: string, prefix: string, indexFields: (keyof T)[] = []): Collection<T> {\n const existing = this.collections.get(name);\n if (existing) {\n if (indexFields.length > 0) {\n const requested = indexFields.map(String).sort();\n if (existing.fieldNames.length !== requested.length || existing.fieldNames.some((f, i) => f !== requested[i])) {\n throw new Error(\n `Collection \"${name}\" already exists with indexes [${existing.fieldNames}] but was requested with [${requested}]`,\n );\n }\n }\n return existing as Collection<T>;\n }\n const col = new Collection<T>(prefix, indexFields);\n this.collections.set(name, col);\n return col;\n }\n\n getData<V>(key: string): V | undefined {\n return this._data.get(key) as V | undefined;\n }\n\n setData<V>(key: string, value: V): void {\n this._data.set(key, value);\n }\n\n deleteDataByPrefix(prefix: string): number {\n let count = 0;\n for (const key of this._data.keys()) {\n if (key.startsWith(prefix)) {\n this._data.delete(key);\n count++;\n }\n }\n return count;\n }\n\n reset(): void {\n for (const collection of this.collections.values()) {\n collection.clear();\n }\n this._data.clear();\n }\n}\n"]}
@@ -0,0 +1,56 @@
1
+ /** Typed keys for Store.getData/setData */
2
+ export declare const STORE_KEYS: {
3
+ readonly workosStore: "_workos_store";
4
+ readonly eventBus: "eventBus";
5
+ readonly apiKeyMap: "apiKeyMap";
6
+ readonly jwtTemplate: "jwt_template";
7
+ };
8
+ /** Prefix for dynamic store keys */
9
+ export declare const STORE_KEY_PREFIXES: {
10
+ readonly pendingAuth: "pending_auth:";
11
+ readonly ssoToken: "sso_token:";
12
+ readonly ssoLogout: "sso_logout:";
13
+ readonly auditSchema: "audit_schema_";
14
+ readonly radarIpList: "radar_ip_list";
15
+ };
16
+ /** All WorkOS webhook event names */
17
+ export declare const EVENTS: {
18
+ readonly userCreated: "user.created";
19
+ readonly userUpdated: "user.updated";
20
+ readonly userDeleted: "user.deleted";
21
+ readonly organizationCreated: "organization.created";
22
+ readonly organizationUpdated: "organization.updated";
23
+ readonly organizationDeleted: "organization.deleted";
24
+ readonly organizationDomainCreated: "organization_domain.created";
25
+ readonly organizationDomainVerified: "organization_domain.verified";
26
+ readonly organizationDomainUpdated: "organization_domain.updated";
27
+ readonly organizationDomainDeleted: "organization_domain.deleted";
28
+ readonly organizationMembershipCreated: "organization_membership.created";
29
+ readonly organizationMembershipUpdated: "organization_membership.updated";
30
+ readonly organizationMembershipDeleted: "organization_membership.deleted";
31
+ readonly connectionCreated: "connection.created";
32
+ readonly connectionUpdated: "connection.updated";
33
+ readonly connectionDeleted: "connection.deleted";
34
+ readonly sessionCreated: "session.created";
35
+ readonly sessionRevoked: "session.revoked";
36
+ readonly invitationCreated: "invitation.created";
37
+ readonly invitationAccepted: "invitation.accepted";
38
+ readonly invitationRevoked: "invitation.revoked";
39
+ readonly invitationResent: "invitation.resent";
40
+ readonly roleCreated: "role.created";
41
+ readonly roleUpdated: "role.updated";
42
+ readonly roleDeleted: "role.deleted";
43
+ readonly permissionCreated: "permission.created";
44
+ readonly permissionUpdated: "permission.updated";
45
+ readonly permissionDeleted: "permission.deleted";
46
+ readonly directoryCreated: "directory.created";
47
+ readonly directoryUpdated: "directory.updated";
48
+ readonly directoryDeleted: "directory.deleted";
49
+ readonly directoryUserCreated: "directory_user.created";
50
+ readonly directoryUserUpdated: "directory_user.updated";
51
+ readonly directoryUserDeleted: "directory_user.deleted";
52
+ readonly directoryGroupCreated: "directory_group.created";
53
+ readonly directoryGroupUpdated: "directory_group.updated";
54
+ readonly directoryGroupDeleted: "directory_group.deleted";
55
+ };
56
+ export type WorkOSEventName = (typeof EVENTS)[keyof typeof EVENTS];
@@ -0,0 +1,56 @@
1
+ /** Typed keys for Store.getData/setData */
2
+ export const STORE_KEYS = {
3
+ workosStore: '_workos_store',
4
+ eventBus: 'eventBus',
5
+ apiKeyMap: 'apiKeyMap',
6
+ jwtTemplate: 'jwt_template',
7
+ };
8
+ /** Prefix for dynamic store keys */
9
+ export const STORE_KEY_PREFIXES = {
10
+ pendingAuth: 'pending_auth:',
11
+ ssoToken: 'sso_token:',
12
+ ssoLogout: 'sso_logout:',
13
+ auditSchema: 'audit_schema_',
14
+ radarIpList: 'radar_ip_list',
15
+ };
16
+ /** All WorkOS webhook event names */
17
+ export const EVENTS = {
18
+ userCreated: 'user.created',
19
+ userUpdated: 'user.updated',
20
+ userDeleted: 'user.deleted',
21
+ organizationCreated: 'organization.created',
22
+ organizationUpdated: 'organization.updated',
23
+ organizationDeleted: 'organization.deleted',
24
+ organizationDomainCreated: 'organization_domain.created',
25
+ organizationDomainVerified: 'organization_domain.verified',
26
+ organizationDomainUpdated: 'organization_domain.updated',
27
+ organizationDomainDeleted: 'organization_domain.deleted',
28
+ organizationMembershipCreated: 'organization_membership.created',
29
+ organizationMembershipUpdated: 'organization_membership.updated',
30
+ organizationMembershipDeleted: 'organization_membership.deleted',
31
+ connectionCreated: 'connection.created',
32
+ connectionUpdated: 'connection.updated',
33
+ connectionDeleted: 'connection.deleted',
34
+ sessionCreated: 'session.created',
35
+ sessionRevoked: 'session.revoked',
36
+ invitationCreated: 'invitation.created',
37
+ invitationAccepted: 'invitation.accepted',
38
+ invitationRevoked: 'invitation.revoked',
39
+ invitationResent: 'invitation.resent',
40
+ roleCreated: 'role.created',
41
+ roleUpdated: 'role.updated',
42
+ roleDeleted: 'role.deleted',
43
+ permissionCreated: 'permission.created',
44
+ permissionUpdated: 'permission.updated',
45
+ permissionDeleted: 'permission.deleted',
46
+ directoryCreated: 'directory.created',
47
+ directoryUpdated: 'directory.updated',
48
+ directoryDeleted: 'directory.deleted',
49
+ directoryUserCreated: 'directory_user.created',
50
+ directoryUserUpdated: 'directory_user.updated',
51
+ directoryUserDeleted: 'directory_user.deleted',
52
+ directoryGroupCreated: 'directory_group.created',
53
+ directoryGroupUpdated: 'directory_group.updated',
54
+ directoryGroupDeleted: 'directory_group.deleted',
55
+ };
56
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["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BAAgB,EAAE,mBAAmB;IACrC,gBAAgB,EAAE,mBAAmB;IACrC,gBAAgB,EAAE,mBAAmB;IACrC,oBAAoB,EAAE,wBAAwB;IAC9C,oBAAoB,EAAE,wBAAwB;IAC9C,oBAAoB,EAAE,wBAAwB;IAC9C,qBAAqB,EAAE,yBAAyB;IAChD,qBAAqB,EAAE,yBAAyB;IAChD,qBAAqB,EAAE,yBAAyB;CACxC,CAAC","sourcesContent":["/** Typed keys for Store.getData/setData */\nexport const STORE_KEYS = {\n workosStore: '_workos_store',\n eventBus: 'eventBus',\n apiKeyMap: 'apiKeyMap',\n jwtTemplate: 'jwt_template',\n} as const;\n\n/** Prefix for dynamic store keys */\nexport const STORE_KEY_PREFIXES = {\n pendingAuth: 'pending_auth:',\n ssoToken: 'sso_token:',\n ssoLogout: 'sso_logout:',\n auditSchema: 'audit_schema_',\n radarIpList: 'radar_ip_list',\n} as const;\n\n/** All WorkOS webhook event names */\nexport const EVENTS = {\n userCreated: 'user.created',\n userUpdated: 'user.updated',\n userDeleted: 'user.deleted',\n organizationCreated: 'organization.created',\n organizationUpdated: 'organization.updated',\n organizationDeleted: 'organization.deleted',\n organizationDomainCreated: 'organization_domain.created',\n organizationDomainVerified: 'organization_domain.verified',\n organizationDomainUpdated: 'organization_domain.updated',\n organizationDomainDeleted: 'organization_domain.deleted',\n organizationMembershipCreated: 'organization_membership.created',\n organizationMembershipUpdated: 'organization_membership.updated',\n organizationMembershipDeleted: 'organization_membership.deleted',\n connectionCreated: 'connection.created',\n connectionUpdated: 'connection.updated',\n connectionDeleted: 'connection.deleted',\n sessionCreated: 'session.created',\n sessionRevoked: 'session.revoked',\n invitationCreated: 'invitation.created',\n invitationAccepted: 'invitation.accepted',\n invitationRevoked: 'invitation.revoked',\n invitationResent: 'invitation.resent',\n roleCreated: 'role.created',\n roleUpdated: 'role.updated',\n roleDeleted: 'role.deleted',\n permissionCreated: 'permission.created',\n permissionUpdated: 'permission.updated',\n permissionDeleted: 'permission.deleted',\n directoryCreated: 'directory.created',\n directoryUpdated: 'directory.updated',\n directoryDeleted: 'directory.deleted',\n directoryUserCreated: 'directory_user.created',\n directoryUserUpdated: 'directory_user.updated',\n directoryUserDeleted: 'directory_user.deleted',\n directoryGroupCreated: 'directory_group.created',\n directoryGroupUpdated: 'directory_group.updated',\n directoryGroupDeleted: 'directory_group.deleted',\n} as const;\n\nexport type WorkOSEventName = (typeof EVENTS)[keyof typeof EVENTS];\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"entities.js","sourceRoot":"","sources":["../../../src/emulate/workos/entities.ts"],"names":[],"mappings":"","sourcesContent":["import type { Entity } from '../core/index.js';\n\nexport interface WorkOSOrganization extends Entity {\n object: 'organization';\n name: string;\n external_id: string | null;\n metadata: Record<string, string>;\n stripe_customer_id: string | null;\n}\n\nexport interface WorkOSOrganizationDomain extends Entity {\n object: 'organization_domain';\n organization_id: string;\n domain: string;\n state: 'verified' | 'pending';\n verification_strategy: 'manual' | 'dns';\n verification_token: string;\n verification_prefix: string;\n}\n\nexport interface WorkOSOrganizationMembership extends Entity {\n object: 'organization_membership';\n organization_id: string;\n user_id: string;\n role: { slug: string };\n status: 'active' | 'inactive' | 'pending';\n external_id: string | null;\n metadata: Record<string, string>;\n}\n\nexport interface WorkOSUser extends Entity {\n object: 'user';\n email: string;\n first_name: string | null;\n last_name: string | null;\n email_verified: boolean;\n profile_picture_url: string | null;\n last_sign_in_at: string | null;\n external_id: string | null;\n metadata: Record<string, string>;\n locale: string | null;\n password_hash: string | null;\n impersonator: { email: string; reason: string } | null;\n}\n\nexport interface WorkOSSession extends Entity {\n object: 'session';\n user_id: string;\n organization_id: string | null;\n ip_address: string | null;\n user_agent: string | null;\n}\n\nexport interface WorkOSEmailVerification extends Entity {\n object: 'email_verification';\n user_id: string;\n email: string;\n code: string;\n expires_at: string;\n}\n\nexport interface WorkOSPasswordReset extends Entity {\n object: 'password_reset';\n user_id: string;\n email: string;\n token: string;\n expires_at: string;\n}\n\nexport interface WorkOSMagicAuth extends Entity {\n object: 'magic_auth';\n user_id: string;\n email: string;\n code: string;\n expires_at: string;\n}\n\nexport interface WorkOSAuthenticationFactor extends Entity {\n object: 'authentication_factor';\n user_id: string;\n type: 'totp';\n totp: {\n issuer: string;\n user: string;\n uri: string;\n };\n}\n\nexport interface WorkOSAuthorizationCode extends Entity {\n user_id: string;\n organization_id: string | null;\n code: string;\n redirect_uri: string;\n expires_at: string;\n code_challenge: string | null;\n code_challenge_method: string | null;\n}\n\nexport interface WorkOSIdentity extends Entity {\n object: 'identity';\n user_id: string;\n provider: string;\n provider_id: string;\n type: 'OAuth';\n}\n\nexport type WorkOSConnectionType =\n | 'ADFSSAML'\n | 'AzureSAML'\n | 'GenericOIDC'\n | 'GenericSAML'\n | 'GoogleOAuth'\n | 'GoogleSAML'\n | 'OktaSAML'\n | 'OneLoginSAML'\n | 'PingFederateSAML'\n | 'PingOneSAML'\n | 'GitHubOAuth'\n | 'MicrosoftOAuth'\n | 'AppleOAuth';\n\nexport interface WorkOSConnectionDomain {\n object: 'connection_domain';\n id: string;\n domain: string;\n}\n\nexport interface WorkOSConnection extends Entity {\n object: 'connection';\n organization_id: string;\n connection_type: WorkOSConnectionType;\n name: string;\n state: 'active' | 'inactive' | 'validating';\n domains: WorkOSConnectionDomain[];\n}\n\nexport interface WorkOSSSOProfile extends Entity {\n object: 'profile';\n connection_id: string;\n connection_type: WorkOSConnectionType;\n organization_id: string;\n idp_id: string;\n email: string;\n first_name: string | null;\n last_name: string | null;\n groups: string[];\n raw_attributes: Record<string, unknown>;\n}\n\nexport interface WorkOSSSOAuthorization extends Entity {\n code: string;\n connection_id: string;\n organization_id: string;\n profile_id: string;\n redirect_uri: string;\n state: string | null;\n expires_at: string;\n}\n\nexport interface WorkOSInvitation extends Entity {\n object: 'invitation';\n email: string;\n state: 'pending' | 'accepted' | 'expired' | 'revoked';\n token: string;\n accept_invitation_url: string;\n organization_id: string | null;\n inviter_user_id: string | null;\n role_slug: string | null;\n expires_at: string;\n}\n\nexport interface WorkOSRedirectUri extends Entity {\n object: 'redirect_uri';\n uri: string;\n}\n\nexport interface WorkOSCorsOrigin extends Entity {\n object: 'cors_origin';\n origin: string;\n}\n\nexport interface WorkOSAuthorizedApplication extends Entity {\n object: 'authorized_application';\n user_id: string;\n name: string;\n redirect_uri: string;\n}\n\nexport interface WorkOSConnectedAccount extends Entity {\n object: 'connected_account';\n user_id: string;\n provider: string;\n provider_id: string;\n}\n\nexport type PipeProvider = 'github' | 'slack' | 'google' | 'salesforce';\nexport type PipeConnectionStatus = 'connected' | 'disconnected' | 'requires_reauth';\n\nexport interface WorkOSPipeConnection extends Entity {\n object: 'pipe_connection';\n user_id: string;\n provider: PipeProvider;\n scopes: string[];\n status: PipeConnectionStatus;\n external_account_id: string | null;\n}\n\nexport interface WorkOSRefreshToken extends Entity {\n token: string;\n user_id: string;\n organization_id: string | null;\n session_id: string;\n expires_at: string;\n}\n\nexport interface WorkOSAuthenticationChallenge extends Entity {\n object: 'authentication_challenge';\n user_id: string;\n factor_id: string;\n expires_at: string;\n code: string | null;\n}\n\nexport interface WorkOSDeviceAuthorization extends Entity {\n device_code: string;\n user_code: string;\n user_id: string | null;\n client_id: string;\n expires_at: string;\n interval: number;\n}\n\nexport interface WorkOSRole extends Entity {\n object: 'role';\n slug: string;\n name: string;\n description: string | null;\n type: 'EnvironmentRole' | 'OrganizationRole';\n organization_id: string | null;\n is_default_role: boolean;\n priority: number;\n}\n\nexport interface WorkOSPermission extends Entity {\n object: 'permission';\n slug: string;\n name: string;\n description: string | null;\n}\n\nexport interface WorkOSRolePermission extends Entity {\n role_id: string;\n permission_id: string;\n}\n\nexport interface WorkOSAuthorizationResource extends Entity {\n object: 'authorization_resource';\n resource_type_slug: string;\n external_id: string;\n organization_id: string;\n metadata: Record<string, string>;\n}\n\nexport interface WorkOSRoleAssignment extends Entity {\n object: 'role_assignment';\n organization_membership_id: string;\n role_id: string;\n}\n\n// --- Phase 4: CRUD Domains ---\n\nexport interface WorkOSDirectory extends Entity {\n object: 'directory';\n name: string;\n organization_id: string | null;\n domain: string | null;\n type: string;\n state: 'linked' | 'unlinked' | 'deleting' | 'invalid_credentials';\n external_key: string | null;\n}\n\nexport interface WorkOSDirectoryUser extends Entity {\n object: 'directory_user';\n directory_id: string;\n organization_id: string | null;\n idp_id: string;\n first_name: string | null;\n last_name: string | null;\n email: string | null;\n username: string | null;\n state: 'active' | 'inactive';\n role: { slug: string } | null;\n custom_attributes: Record<string, unknown>;\n raw_attributes: Record<string, unknown>;\n groups: Array<{ object: 'directory_group'; id: string; name: string }>;\n}\n\nexport interface WorkOSDirectoryGroup extends Entity {\n object: 'directory_group';\n directory_id: string;\n organization_id: string | null;\n idp_id: string;\n name: string;\n raw_attributes: Record<string, unknown>;\n}\n\nexport interface WorkOSAuditLogAction extends Entity {\n object: 'audit_log_action';\n name: string;\n description: string | null;\n condition: string | null;\n}\n\nexport interface WorkOSAuditLogEvent extends Entity {\n object: 'audit_log_event';\n organization_id: string;\n action: { name: string; type: string; id: string };\n actor: Record<string, unknown>;\n targets: Array<Record<string, unknown>>;\n metadata: Record<string, unknown> | null;\n occurred_at: string;\n}\n\nexport interface WorkOSAuditLogExport extends Entity {\n object: 'audit_log_export';\n organization_id: string;\n state: 'pending' | 'ready' | 'error';\n url: string | null;\n filters: Record<string, unknown>;\n}\n\nexport interface WorkOSFeatureFlag extends Entity {\n object: 'feature_flag';\n slug: string;\n name: string;\n description: string | null;\n type: 'boolean' | 'string' | 'number';\n default_value: unknown;\n enabled: boolean;\n}\n\nexport interface WorkOSFlagTarget extends Entity {\n object: 'flag_target';\n flag_slug: string;\n resource_id: string;\n resource_type: string;\n value: unknown;\n}\n\nexport interface WorkOSConnectApplication extends Entity {\n object: 'connect_application';\n name: string;\n redirect_uris: string[];\n client_id: string;\n logo_url: string | null;\n}\n\nexport interface WorkOSClientSecret extends Entity {\n object: 'client_secret';\n application_id: string;\n value: string;\n last_four: string;\n}\n\nexport interface WorkOSDataIntegrationAuth extends Entity {\n slug: string;\n code: string;\n redirect_uri: string;\n state: string | null;\n expires_at: string;\n}\n\nexport interface WorkOSRadarAttempt extends Entity {\n object: 'radar_attempt';\n user_id: string | null;\n ip_address: string;\n user_agent: string | null;\n verdict: 'allow' | 'deny' | 'challenge';\n signals: Array<{ type: string; confidence: number }>;\n}\n\nexport interface WorkOSApiKey extends Entity {\n object: 'api_key';\n name: string;\n key: string;\n environment: string;\n}\n\nexport interface WorkOSEvent extends Entity {\n object: 'event';\n event: string;\n data: Record<string, unknown>;\n environment_id: string | null;\n}\n\nexport interface WorkOSWebhookEndpoint extends Entity {\n object: 'webhook_endpoint';\n url: string;\n secret: string;\n enabled: boolean;\n events: string[];\n description: string | null;\n}\n"]}
1
+ {"version":3,"file":"entities.js","sourceRoot":"","sources":["../../../src/emulate/workos/entities.ts"],"names":[],"mappings":"","sourcesContent":["import type { Entity } from '../core/index.js';\n\nexport interface WorkOSOrganization extends Entity {\n object: 'organization';\n name: string;\n external_id: string | null;\n metadata: Record<string, string>;\n stripe_customer_id: string | null;\n}\n\nexport interface WorkOSOrganizationDomain extends Entity {\n object: 'organization_domain';\n organization_id: string;\n domain: string;\n state: 'verified' | 'pending';\n verification_strategy: 'manual' | 'dns';\n verification_token: string;\n verification_prefix: string;\n}\n\nexport interface WorkOSOrganizationMembership extends Entity {\n object: 'organization_membership';\n organization_id: string;\n user_id: string;\n role: { slug: string };\n status: 'active' | 'inactive' | 'pending';\n external_id: string | null;\n metadata: Record<string, string>;\n}\n\nexport interface WorkOSUser extends Entity {\n object: 'user';\n email: string;\n first_name: string | null;\n last_name: string | null;\n email_verified: boolean;\n profile_picture_url: string | null;\n last_sign_in_at: string | null;\n external_id: string | null;\n metadata: Record<string, string>;\n locale: string | null;\n password_hash: string | null;\n impersonator: { email: string; reason: string } | null;\n}\n\nexport interface WorkOSSession extends Entity {\n object: 'session';\n user_id: string;\n organization_id: string | null;\n ip_address: string | null;\n user_agent: string | null;\n}\n\nexport interface WorkOSEmailVerification extends Entity {\n object: 'email_verification';\n user_id: string;\n email: string;\n code: string;\n expires_at: string;\n}\n\nexport interface WorkOSPasswordReset extends Entity {\n object: 'password_reset';\n user_id: string;\n email: string;\n token: string;\n expires_at: string;\n}\n\nexport interface WorkOSMagicAuth extends Entity {\n object: 'magic_auth';\n user_id: string;\n email: string;\n code: string;\n expires_at: string;\n}\n\nexport interface WorkOSAuthenticationFactor extends Entity {\n object: 'authentication_factor';\n user_id: string;\n type: 'totp';\n totp: {\n issuer: string;\n user: string;\n uri: string;\n };\n}\n\nexport interface WorkOSAuthorizationCode extends Entity {\n user_id: string;\n organization_id: string | null;\n code: string;\n redirect_uri: string;\n expires_at: string;\n code_challenge: string | null;\n code_challenge_method: string | null;\n}\n\nexport interface WorkOSIdentity extends Entity {\n object: 'identity';\n user_id: string;\n provider: string;\n provider_id: string;\n type: 'OAuth';\n}\n\nexport type WorkOSConnectionType =\n | 'ADFSSAML'\n | 'AzureSAML'\n | 'GenericOIDC'\n | 'GenericSAML'\n | 'GoogleOAuth'\n | 'GoogleSAML'\n | 'OktaSAML'\n | 'OneLoginSAML'\n | 'PingFederateSAML'\n | 'PingOneSAML'\n | 'GitHubOAuth'\n | 'MicrosoftOAuth'\n | 'AppleOAuth';\n\nexport interface WorkOSConnectionDomain {\n object: 'connection_domain';\n id: string;\n domain: string;\n}\n\nexport interface WorkOSConnection extends Entity {\n object: 'connection';\n organization_id: string;\n connection_type: WorkOSConnectionType;\n name: string;\n state: 'active' | 'inactive' | 'validating';\n domains: WorkOSConnectionDomain[];\n}\n\nexport interface WorkOSSSOProfile extends Entity {\n object: 'profile';\n connection_id: string;\n connection_type: WorkOSConnectionType;\n organization_id: string;\n idp_id: string;\n email: string;\n first_name: string | null;\n last_name: string | null;\n groups: string[];\n raw_attributes: Record<string, unknown>;\n}\n\nexport interface WorkOSSSOAuthorization extends Entity {\n code: string;\n connection_id: string;\n organization_id: string;\n profile_id: string;\n redirect_uri: string;\n state: string | null;\n expires_at: string;\n}\n\nexport interface WorkOSInvitation extends Entity {\n object: 'invitation';\n email: string;\n state: 'pending' | 'accepted' | 'expired' | 'revoked';\n token: string;\n accept_invitation_url: string;\n organization_id: string | null;\n inviter_user_id: string | null;\n role_slug: string | null;\n expires_at: string;\n}\n\nexport interface WorkOSRedirectUri extends Entity {\n object: 'redirect_uri';\n uri: string;\n}\n\nexport interface WorkOSCorsOrigin extends Entity {\n object: 'cors_origin';\n origin: string;\n}\n\nexport interface WorkOSAuthorizedApplication extends Entity {\n object: 'authorized_application';\n user_id: string;\n name: string;\n redirect_uri: string;\n}\n\nexport interface WorkOSConnectedAccount extends Entity {\n object: 'connected_account';\n user_id: string;\n provider: string;\n provider_id: string;\n}\n\nexport type PipeProvider = 'github' | 'slack' | 'google' | 'salesforce';\nexport type PipeConnectionStatus = 'connected' | 'disconnected' | 'requires_reauth';\n\nexport interface WorkOSPipeConnection extends Entity {\n object: 'pipe_connection';\n user_id: string;\n provider: PipeProvider;\n scopes: string[];\n status: PipeConnectionStatus;\n external_account_id: string | null;\n}\n\nexport interface WorkOSRefreshToken extends Entity {\n token: string;\n user_id: string;\n organization_id: string | null;\n session_id: string;\n expires_at: string;\n}\n\nexport interface WorkOSAuthenticationChallenge extends Entity {\n object: 'authentication_challenge';\n user_id: string;\n factor_id: string;\n expires_at: string;\n code: string | null;\n}\n\nexport interface WorkOSDeviceAuthorization extends Entity {\n device_code: string;\n user_code: string;\n user_id: string | null;\n client_id: string;\n expires_at: string;\n interval: number;\n}\n\nexport interface WorkOSRole extends Entity {\n object: 'role';\n slug: string;\n name: string;\n description: string | null;\n type: 'EnvironmentRole' | 'OrganizationRole';\n organization_id: string | null;\n is_default_role: boolean;\n priority: number;\n}\n\nexport interface WorkOSPermission extends Entity {\n object: 'permission';\n slug: string;\n name: string;\n description: string | null;\n}\n\nexport interface WorkOSRolePermission extends Entity {\n role_id: string;\n permission_id: string;\n}\n\nexport interface WorkOSAuthorizationResource extends Entity {\n object: 'authorization_resource';\n resource_type_slug: string;\n external_id: string;\n organization_id: string;\n metadata: Record<string, string>;\n}\n\nexport interface WorkOSRoleAssignment extends Entity {\n object: 'role_assignment';\n organization_membership_id: string;\n role_id: string;\n}\n\nexport interface WorkOSDirectory extends Entity {\n object: 'directory';\n name: string;\n organization_id: string | null;\n domain: string | null;\n type: string;\n state: 'linked' | 'unlinked' | 'deleting' | 'invalid_credentials';\n external_key: string | null;\n}\n\nexport interface WorkOSDirectoryUser extends Entity {\n object: 'directory_user';\n directory_id: string;\n organization_id: string | null;\n idp_id: string;\n first_name: string | null;\n last_name: string | null;\n email: string | null;\n username: string | null;\n state: 'active' | 'inactive';\n role: { slug: string } | null;\n custom_attributes: Record<string, unknown>;\n raw_attributes: Record<string, unknown>;\n groups: Array<{ object: 'directory_group'; id: string; name: string }>;\n}\n\nexport interface WorkOSDirectoryGroup extends Entity {\n object: 'directory_group';\n directory_id: string;\n organization_id: string | null;\n idp_id: string;\n name: string;\n raw_attributes: Record<string, unknown>;\n}\n\nexport interface WorkOSAuditLogAction extends Entity {\n object: 'audit_log_action';\n name: string;\n description: string | null;\n condition: string | null;\n}\n\nexport interface WorkOSAuditLogEvent extends Entity {\n object: 'audit_log_event';\n organization_id: string;\n action: { name: string; type: string; id: string };\n actor: Record<string, unknown>;\n targets: Array<Record<string, unknown>>;\n metadata: Record<string, unknown> | null;\n occurred_at: string;\n}\n\nexport interface WorkOSAuditLogExport extends Entity {\n object: 'audit_log_export';\n organization_id: string;\n state: 'pending' | 'ready' | 'error';\n url: string | null;\n filters: Record<string, unknown>;\n}\n\nexport interface WorkOSFeatureFlag extends Entity {\n object: 'feature_flag';\n slug: string;\n name: string;\n description: string | null;\n type: 'boolean' | 'string' | 'number';\n default_value: unknown;\n enabled: boolean;\n}\n\nexport interface WorkOSFlagTarget extends Entity {\n object: 'flag_target';\n flag_slug: string;\n resource_id: string;\n resource_type: string;\n value: unknown;\n}\n\nexport interface WorkOSConnectApplication extends Entity {\n object: 'connect_application';\n name: string;\n redirect_uris: string[];\n client_id: string;\n logo_url: string | null;\n}\n\nexport interface WorkOSClientSecret extends Entity {\n object: 'client_secret';\n application_id: string;\n value: string;\n last_four: string;\n}\n\nexport interface WorkOSDataIntegrationAuth extends Entity {\n slug: string;\n code: string;\n redirect_uri: string;\n state: string | null;\n expires_at: string;\n}\n\nexport interface WorkOSRadarAttempt extends Entity {\n object: 'radar_attempt';\n user_id: string | null;\n ip_address: string;\n user_agent: string | null;\n verdict: 'allow' | 'deny' | 'challenge';\n signals: Array<{ type: string; confidence: number }>;\n}\n\nexport interface WorkOSApiKey extends Entity {\n object: 'api_key';\n name: string;\n key: string;\n environment: string;\n}\n\nexport interface WorkOSEvent extends Entity {\n object: 'event';\n event: string;\n data: Record<string, unknown>;\n environment_id: string | null;\n}\n\nexport interface WorkOSWebhookEndpoint extends Entity {\n object: 'webhook_endpoint';\n url: string;\n secret: string;\n enabled: boolean;\n events: string[];\n description: string | null;\n}\n"]}
@@ -1,12 +1,17 @@
1
1
  import type { Store } from '../core/index.js';
2
+ import type { WorkOSEventName } from './constants.js';
2
3
  export interface EventPayload {
3
- event: string;
4
+ event: WorkOSEventName | string;
4
5
  data: Record<string, unknown>;
5
6
  environment_id?: string;
6
7
  }
7
8
  export declare class EventBus {
8
9
  private store;
10
+ private endpointsByEvent;
11
+ private catchAllEndpoints;
9
12
  constructor(store: Store);
13
+ /** Rebuild the event-type index. Auto-called via collection hooks; call manually only in tests. */
14
+ rebuildIndex(): void;
10
15
  emit(payload: EventPayload): void;
11
16
  private deliver;
12
17
  }
@@ -2,9 +2,31 @@ import { getWorkOSStore } from './store.js';
2
2
  import { signWebhookPayload } from './webhook-signer.js';
3
3
  export class EventBus {
4
4
  store;
5
+ endpointsByEvent = new Map();
6
+ catchAllEndpoints = new Set();
5
7
  constructor(store) {
6
8
  this.store = store;
7
9
  }
10
+ /** Rebuild the event-type index. Auto-called via collection hooks; call manually only in tests. */
11
+ rebuildIndex() {
12
+ this.endpointsByEvent.clear();
13
+ this.catchAllEndpoints.clear();
14
+ const ws = getWorkOSStore(this.store);
15
+ for (const ep of ws.webhookEndpoints.all()) {
16
+ if (!ep.enabled)
17
+ continue;
18
+ if (ep.events.length === 0) {
19
+ this.catchAllEndpoints.add(ep.id);
20
+ }
21
+ else {
22
+ for (const evt of ep.events) {
23
+ const set = this.endpointsByEvent.get(evt) ?? new Set();
24
+ set.add(ep.id);
25
+ this.endpointsByEvent.set(evt, set);
26
+ }
27
+ }
28
+ }
29
+ }
8
30
  emit(payload) {
9
31
  const ws = getWorkOSStore(this.store);
10
32
  const event = ws.events.insert({
@@ -13,14 +35,17 @@ export class EventBus {
13
35
  data: payload.data,
14
36
  environment_id: payload.environment_id ?? null,
15
37
  });
16
- const endpoints = ws.webhookEndpoints.all();
17
- for (const endpoint of endpoints) {
18
- if (!endpoint.enabled)
19
- continue;
20
- if (endpoint.events.length > 0 && !endpoint.events.includes(payload.event))
21
- continue;
22
- // Fire-and-forget — don't await
23
- this.deliver(endpoint, event).catch(() => { });
38
+ // Pre-filtered: only endpoints that care about this event
39
+ const targetIds = new Set(this.catchAllEndpoints);
40
+ const eventSpecific = this.endpointsByEvent.get(payload.event);
41
+ if (eventSpecific) {
42
+ for (const id of eventSpecific)
43
+ targetIds.add(id);
44
+ }
45
+ for (const id of targetIds) {
46
+ const endpoint = ws.webhookEndpoints.get(id);
47
+ if (endpoint)
48
+ this.deliver(endpoint, event).catch(() => { });
24
49
  }
25
50
  }
26
51
  async deliver(endpoint, event) {
@@ -1 +1 @@
1
- {"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../../../src/emulate/workos/event-bus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAQzD,MAAM,OAAO,QAAQ;IACC;IAApB,YAAoB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;IAAG,CAAC;IAEpC,IAAI,CAAC,OAAqB;QACxB,MA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;aAC9B;YACD,IAAI;YACJ,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC;SAClC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type { Store } from '../core/index.js';\nimport { getWorkOSStore } from './store.js';\nimport type { WorkOSWebhookEndpoint, WorkOSEvent } from './entities.js';\nimport { signWebhookPayload } from './webhook-signer.js';\n\nexport interface EventPayload {\n event: string;\n data: Record<string, unknown>;\n environment_id?: string;\n}\n\nexport class EventBus {\n constructor(private store: Store) {}\n\n emit(payload: EventPayload): void {\n const ws = getWorkOSStore(this.store);\n\n const event = ws.events.insert({\n object: 'event',\n event: payload.event,\n data: payload.data,\n environment_id: payload.environment_id ?? null,\n });\n\n const endpoints = ws.webhookEndpoints.all();\n for (const endpoint of endpoints) {\n if (!endpoint.enabled) continue;\n if (endpoint.events.length > 0 && !endpoint.events.includes(payload.event)) continue;\n // Fire-and-forget — don't await\n this.deliver(endpoint, event).catch(() => {});\n }\n }\n\n private async deliver(endpoint: WorkOSWebhookEndpoint, event: WorkOSEvent): Promise<void> {\n const body = JSON.stringify({\n id: event.id,\n event: event.event,\n data: event.data,\n created_at: event.created_at,\n });\n\n const signature = signWebhookPayload(body, endpoint.secret);\n\n await fetch(endpoint.url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'WorkOS-Signature': signature,\n },\n body,\n signal: AbortSignal.timeout(5000),\n });\n }\n}\n"]}
1
+ {"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../../../src/emulate/workos/event-bus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AASzD,MAAM,OAAO,QAAQ;IAIC;IAHZ,gBAAgB,GAAG,IAAI,GAAG,EAAuB,CAAC;IAClD,iBAAiB,GAAG,IAAI,GAAG,EAAU,CAAC;IAE9C,YAAoB,KAAY;QAAZ,UAAK,GAAL,KA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from './entities.js';\nimport { signWebhookPayload } from './webhook-signer.js';\nimport type { WorkOSEventName } from './constants.js';\n\nexport interface EventPayload {\n event: WorkOSEventName | string;\n data: Record<string, unknown>;\n environment_id?: string;\n}\n\nexport class EventBus {\n private endpointsByEvent = new Map<string, Set<string>>();\n private catchAllEndpoints = new Set<string>();\n\n constructor(private store: Store) {}\n\n /** Rebuild the event-type index. Auto-called via collection hooks; call manually only in tests. */\n rebuildIndex(): void {\n this.endpointsByEvent.clear();\n this.catchAllEndpoints.clear();\n const ws = getWorkOSStore(this.store);\n for (const ep of ws.webhookEndpoints.all()) {\n if (!ep.enabled) continue;\n if (ep.events.length === 0) {\n this.catchAllEndpoints.add(ep.id);\n } else {\n for (const evt of ep.events) {\n const set = this.endpointsByEvent.get(evt) ?? new Set();\n set.add(ep.id);\n this.endpointsByEvent.set(evt, set);\n }\n }\n }\n }\n\n emit(payload: EventPayload): void {\n const ws = getWorkOSStore(this.store);\n\n const event = ws.events.insert({\n object: 'event',\n event: payload.event,\n data: payload.data,\n environment_id: payload.environment_id ?? null,\n });\n\n // Pre-filtered: only endpoints that care about this event\n const targetIds = new Set(this.catchAllEndpoints);\n const eventSpecific = this.endpointsByEvent.get(payload.event);\n if (eventSpecific) {\n for (const id of eventSpecific) targetIds.add(id);\n }\n\n for (const id of targetIds) {\n const endpoint = ws.webhookEndpoints.get(id);\n if (endpoint) this.deliver(endpoint, event).catch(() => {});\n }\n }\n\n private async deliver(endpoint: WorkOSWebhookEndpoint, event: WorkOSEvent): Promise<void> {\n const body = JSON.stringify({\n id: event.id,\n event: event.event,\n data: event.data,\n created_at: event.created_at,\n });\n\n const signature = signWebhookPayload(body, endpoint.secret);\n\n await fetch(endpoint.url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'WorkOS-Signature': signature,\n },\n body,\n signal: AbortSignal.timeout(5000),\n });\n }\n}\n"]}
@@ -1,6 +1,20 @@
1
+ import { type CursorPaginatedResult, type Entity } from '../core/index.js';
1
2
  import type { WorkOSStore } from './store.js';
2
- import type { WorkOSOrganization, WorkOSOrganizationDomain, WorkOSOrganizationMembership, WorkOSUser, WorkOSSession, WorkOSEmailVerification, WorkOSPasswordReset, WorkOSMagicAuth, WorkOSAuthenticationFactor, WorkOSIdentity, WorkOSConnection, WorkOSSSOProfile, WorkOSPipeConnection, WorkOSInvitation, WorkOSRedirectUri, WorkOSCorsOrigin, WorkOSAuthorizedApplication, WorkOSConnectedAccount, WorkOSAuthenticationChallenge, WorkOSDeviceAuthorization, WorkOSRole, WorkOSPermission, WorkOSAuthorizationResource, WorkOSRoleAssignment, WorkOSDirectory, WorkOSDirectoryUser, WorkOSDirectoryGroup, WorkOSAuditLogAction, WorkOSAuditLogEvent, WorkOSAuditLogExport, WorkOSFeatureFlag, WorkOSConnectApplication, WorkOSClientSecret, WorkOSRadarAttempt, WorkOSApiKey, WorkOSEvent, WorkOSWebhookEndpoint } from './entities.js';
3
- export declare function formatOrganization(org: WorkOSOrganization, ws: WorkOSStore): Record<string, unknown>;
3
+ import type { WorkOSOrganization, WorkOSOrganizationDomain, WorkOSOrganizationMembership, WorkOSUser, WorkOSSession, WorkOSEmailVerification, WorkOSPasswordReset, WorkOSMagicAuth, WorkOSAuthenticationFactor, WorkOSIdentity, WorkOSConnection, WorkOSSSOProfile, WorkOSPipeConnection, WorkOSInvitation, WorkOSRedirectUri, WorkOSCorsOrigin, WorkOSAuthorizedApplication, WorkOSConnectedAccount, WorkOSAuthenticationChallenge, WorkOSDeviceAuthorization, WorkOSRole, WorkOSPermission, WorkOSAuthorizationResource, WorkOSRoleAssignment, WorkOSDirectory, WorkOSDirectoryUser, WorkOSDirectoryGroup, WorkOSAuditLogAction, WorkOSAuditLogEvent, WorkOSAuditLogExport, WorkOSFeatureFlag, WorkOSFlagTarget, WorkOSConnectApplication, WorkOSClientSecret, WorkOSRadarAttempt, WorkOSApiKey, WorkOSEvent, WorkOSWebhookEndpoint } from './entities.js';
4
+ export declare function formatEntity<T extends Entity>(entity: T, opts?: {
5
+ exclude?: Set<string>;
6
+ }): Record<string, unknown>;
7
+ export declare function formatListResponse<T>(result: CursorPaginatedResult<T>, formatter: (item: T) => Record<string, unknown>): {
8
+ object: 'list';
9
+ data: Record<string, unknown>[];
10
+ list_metadata: {
11
+ before: string | null;
12
+ after: string | null;
13
+ };
14
+ };
15
+ export declare function formatOrganization(org: WorkOSOrganization, ws: WorkOSStore, opts?: {
16
+ domains?: WorkOSOrganizationDomain[];
17
+ }): Record<string, unknown>;
4
18
  export declare function formatDomain(domain: WorkOSOrganizationDomain): Record<string, unknown>;
5
19
  export declare function formatMembership(m: WorkOSOrganizationMembership): Record<string, unknown>;
6
20
  export declare function formatUser(user: WorkOSUser): Record<string, unknown>;
@@ -24,12 +38,6 @@ export declare function formatRedirectUri(r: WorkOSRedirectUri): Record<string,
24
38
  export declare function formatCorsOrigin(o: WorkOSCorsOrigin): Record<string, unknown>;
25
39
  export declare function formatAuthorizedApplication(a: WorkOSAuthorizedApplication): Record<string, unknown>;
26
40
  export declare function formatConnectedAccount(a: WorkOSConnectedAccount): Record<string, unknown>;
27
- export declare function parseListParams(url: URL): {
28
- limit: number;
29
- order: "asc" | "desc";
30
- before: string | undefined;
31
- after: string | undefined;
32
- };
33
41
  /**
34
42
  * Validate that a redirect_uri points to a localhost origin.
35
43
  * Prevents the emulator from being used as an open redirect.
@@ -48,6 +56,7 @@ export declare function formatAuditLogAction(a: WorkOSAuditLogAction): Record<st
48
56
  export declare function formatAuditLogEvent(e: WorkOSAuditLogEvent): Record<string, unknown>;
49
57
  export declare function formatAuditLogExport(ex: WorkOSAuditLogExport): Record<string, unknown>;
50
58
  export declare function formatFeatureFlag(f: WorkOSFeatureFlag): Record<string, unknown>;
59
+ export declare function formatFlagTarget(t: WorkOSFlagTarget): Record<string, unknown>;
51
60
  export declare function formatConnectApplication(a: WorkOSConnectApplication): Record<string, unknown>;
52
61
  export declare function formatClientSecret(s: WorkOSClientSecret): Record<string, unknown>;
53
62
  export declare function formatRadarAttempt(a: WorkOSRadarAttempt): Record<string, unknown>;