processfocus 0.1.0-next.4 → 0.1.0-next.5

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/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ export type { CamelCase, FlowContext, ForEachOutput, FormStepMeta, MergeFormStep
7
7
  export { type ConditionOptions, ElseBranch, type ElseTransitionOptions, FlowPath, type MergeState, type OnErrorOptions, type ScheduleOptions, type TransitionOptions, } from "./process/src/lib/flow-path.js";
8
8
  export { Form, type FormEmbedConfig, type FormPublicCompletionConfig, type FormStepProps, LookupFieldNotFoundError, type PublicCompletionCorrectionConfig, type PublicCompletionEmailTemplate, type PublicCompletionRecipient, type Summary, } from "./process/src/lib/form.js";
9
9
  export { Invitation, type InvitationProps, } from "./process/src/lib/invitation.js";
10
- export { DEFAULT_PAGE_SIZE, List, type ListDeleteFunction, type ListItemQueryContext, type ListItemQueryFunction, type ListProps, type ListQueryContext, type ListQueryFunction, type ListQueryResult, type ListSortDirection, type ListSortInput, ListSortable, type ListUpdateFunction, ListUpdateValidationError, ListVisibleInList, MAX_PAGE_SIZE, type OutputItem, } from "./process/src/lib/list.js";
10
+ export { DEFAULT_PAGE_SIZE, List, type ListDeleteFunction, type ListItemQueryContext, type ListItemQueryFunction, type ListProps, type ListQueryContext, type ListQueryFunction, type ListQueryResult, type ListSortDirection, type ListSortInput, ListSortable, type ListUpdateFunction, ListUpdateValidationError, ListVisibleInList, MAX_PAGE_SIZE, type OutputItem, markRawSqlWrite, } from "./process/src/lib/list.js";
11
11
  export { type DependentQueryInput, LookupAccessor, LookupBuilder, type QueryInput, } from "./process/src/lib/lookup-accessor.js";
12
12
  export { NodeStep, type NodeStepProps, } from "./process/src/lib/node_step.js";
13
13
  export { OrgUnit, type OrgUnitProps, type OrgUnitType, } from "./process/src/lib/org-unit.js";
package/dist/index.mjs CHANGED
@@ -1,9 +1,10 @@
1
- import { At as FormProviderUserInput, B as METRIC_BREAKDOWN_SYMBOL, C as CurrentProviderUser, D as FLATTEN_SYMBOL, N as LINK_TEXT_SYMBOL, Nt as FormRequired, P as LINK_URL_SYMBOL, Pt as FormStaticText, Z as TEXTBLOCK_CONTENT_SYMBOL, _ as hasFlattenAnnotation, _t as FormDefault, dt as FormAutoComplete, f as DeferredValueTypeId, g as fieldInputAst, h as fieldAnnotation, m as isDeferredValue, p as FormDeferredContent, pt as FormCalendarSlotInput, q as STRUCTURAL_ONLY_SYMBOL, tt as TextBlock, ut as isMetricBreakdownOptions, v as hasStructuralOnlyAnnotation, vt as FormDescription, wt as FormLookupInput, xt as FormLabel, y as isReadOnlyField } from "./src-BQ55-khF.mjs";
2
- import { _ as AuthenticationConfig, a as KeycloakOAuthProviderConfigSchema, c as OAuthProviderConfigSchema, d as SecretClientConfigSchema, f as SlackOAuthProviderConfigSchema, g as isCustomEntitiesConfig, h as CustomEntitiesConfig, i as GoogleOAuthProviderConfigSchema, l as OAuthProviderNameSchema, m as isPoliciesConfig, n as CognitoOAuthProviderConfigSchema, o as MicrosoftOAuthProviderConfigSchema, p as PoliciesConfig, r as DEFAULT_OAUTH_PROVIDER_SCOPES, s as OAUTH_PROVIDER_NAMES, t as AppleOAuthProviderConfigSchema, u as PasskeyProviderConfigSchema, v as isAuthenticationConfig } from "./auth-DWWupwJA.mjs";
3
1
  import { Construct } from "constructs";
4
2
  import { Array as Array$1, Context, Data, Duration, Effect, Match, Option, Result, Schema, SchemaAST, SchemaGetter, String as String$1 } from "effect";
3
+ import { At as FormProviderUserInput, B as METRIC_BREAKDOWN_SYMBOL, C as CurrentProviderUser, D as FLATTEN_SYMBOL, N as LINK_TEXT_SYMBOL, Nt as FormRequired, P as LINK_URL_SYMBOL, Pt as FormStaticText, Z as TEXTBLOCK_CONTENT_SYMBOL, _ as hasFlattenAnnotation, _t as FormDefault, dt as FormAutoComplete, f as DeferredValueTypeId, g as fieldInputAst, h as fieldAnnotation, m as isDeferredValue, p as FormDeferredContent, pt as FormCalendarSlotInput, q as STRUCTURAL_ONLY_SYMBOL, tt as TextBlock, ut as isMetricBreakdownOptions, v as hasStructuralOnlyAnnotation, vt as FormDescription, wt as FormLookupInput, xt as FormLabel, y as isReadOnlyField } from "./src-BQ55-khF.mjs";
5
4
  import * as AST from "effect/SchemaAST";
5
+ import { SqlClient } from "effect/sql/SqlClient";
6
6
  import DirectedGraph from "graphology";
7
+ import { _ as AuthenticationConfig, a as KeycloakOAuthProviderConfigSchema, c as OAuthProviderConfigSchema, d as SecretClientConfigSchema, f as SlackOAuthProviderConfigSchema, g as isCustomEntitiesConfig, h as CustomEntitiesConfig, i as GoogleOAuthProviderConfigSchema, l as OAuthProviderNameSchema, m as isPoliciesConfig, n as CognitoOAuthProviderConfigSchema, o as MicrosoftOAuthProviderConfigSchema, p as PoliciesConfig, r as DEFAULT_OAUTH_PROVIDER_SCOPES, s as OAUTH_PROVIDER_NAMES, t as AppleOAuthProviderConfigSchema, u as PasskeyProviderConfigSchema, v as isAuthenticationConfig } from "./auth-DWWupwJA.mjs";
7
8
  // ../process/src/lib/app-icons.ts
8
9
  const VALID_MANIFEST_ICON_PURPOSES = /* @__PURE__ */ new Set([
9
10
  "any",
@@ -39,7 +40,7 @@ const isRole = (value) => hasBrand(value, "isRole");
39
40
  const isStatsView = (value) => hasBrand(value, "isStatsView");
40
41
  const isStep = (value) => hasBrand(value, "isStep");
41
42
  // ../process/src/lib/document-store.ts
42
- const DEFAULT_MAX_FILE_SIZE = 104857600;
43
+ const DEFAULT_MAX_FILE_SIZE = 0x6400000;
43
44
  /**
44
45
  * A document store for file uploads and downloads.
45
46
  *
@@ -931,7 +932,7 @@ const pathToPascalCase = (path) => {
931
932
  * toCamelCase("my-step") // "myStep"
932
933
  * toCamelCase("123 invalid start") // "invalidStart" (removes leading digits)
933
934
  */
934
- function toCamelCase(str) {
935
+ function toCamelCase$1(str) {
935
936
  const words = str.split(/[\s_-]+/).filter((w) => w.length > 0);
936
937
  if (words.length === 0) return "unnamed";
937
938
  let isFirstWord = true;
@@ -1024,7 +1025,7 @@ var Step = class extends Construct {
1024
1025
  this.process = process;
1025
1026
  this._output = props.output;
1026
1027
  this.props = props;
1027
- this.stepKey = toCamelCase(id);
1028
+ this.stepKey = toCamelCase$1(id);
1028
1029
  process.addNode(this);
1029
1030
  }
1030
1031
  /**
@@ -1922,7 +1923,912 @@ var Invitation = class extends Construct {
1922
1923
  this.roles = props.roles;
1923
1924
  }
1924
1925
  };
1926
+ // ../../node_modules/.bun/drizzle-orm@1.0.0-rc.6+de0f8d2b751ff1e4/node_modules/drizzle-orm/entity.js
1927
+ const entityKind = Symbol.for("drizzle:entityKind");
1928
+ const kindsByConstructor = /* @__PURE__ */ new WeakMap();
1929
+ function collectKinds(ctor) {
1930
+ const kinds = /* @__PURE__ */ new Set();
1931
+ for (let cls = ctor; cls; cls = Object.getPrototypeOf(cls)) if (entityKind in cls) kinds.add(cls[entityKind]);
1932
+ kindsByConstructor.set(ctor, kinds);
1933
+ return kinds;
1934
+ }
1935
+ const nativeHasInstance = Function.prototype[Symbol.hasInstance];
1936
+ function is(value, type) {
1937
+ if (nativeHasInstance.call(type, value)) return true;
1938
+ if (value === null || typeof value !== "object") return false;
1939
+ const ctor = Object.getPrototypeOf(value)?.constructor;
1940
+ if (typeof ctor !== "function") return false;
1941
+ return (kindsByConstructor.get(ctor) ?? collectKinds(ctor)).has(type[entityKind]);
1942
+ }
1943
+ function entityKindsOf(value) {
1944
+ if (value === null || typeof value !== "object") return void 0;
1945
+ const ctor = Object.getPrototypeOf(value)?.constructor;
1946
+ if (typeof ctor !== "function") return void 0;
1947
+ return kindsByConstructor.get(ctor) ?? collectKinds(ctor);
1948
+ }
1949
+ // ../../node_modules/.bun/drizzle-orm@1.0.0-rc.6+de0f8d2b751ff1e4/node_modules/drizzle-orm/column-common.js
1950
+ const OriginalColumn = Symbol.for("drizzle:OriginalColumn");
1951
+ // ../../node_modules/.bun/drizzle-orm@1.0.0-rc.6+de0f8d2b751ff1e4/node_modules/drizzle-orm/column.js
1952
+ const noop = (v) => v;
1953
+ noop.isNoop = true;
1954
+ var Column = class {
1955
+ static [entityKind] = "Column";
1956
+ static [Symbol.hasInstance](value) {
1957
+ return is(value, this);
1958
+ }
1959
+ /** @internal */
1960
+ codec;
1961
+ name;
1962
+ keyAsName;
1963
+ primary;
1964
+ notNull;
1965
+ default;
1966
+ defaultFn;
1967
+ onUpdateFn;
1968
+ hasDefault;
1969
+ isUnique;
1970
+ uniqueName;
1971
+ uniqueType;
1972
+ dataType;
1973
+ columnType;
1974
+ enumValues = void 0;
1975
+ generated = void 0;
1976
+ generatedIdentity = void 0;
1977
+ length;
1978
+ isLengthExact;
1979
+ isAlias;
1980
+ /** @internal */
1981
+ config;
1982
+ /** @internal */
1983
+ table;
1984
+ /** @internal */
1985
+ onInit() {}
1986
+ constructor(table, config) {
1987
+ this.config = config;
1988
+ this.onInit();
1989
+ this.table = table;
1990
+ this.name = config.name;
1991
+ this.isAlias = false;
1992
+ this.keyAsName = config.keyAsName;
1993
+ this.notNull = config.notNull;
1994
+ this.default = config.default;
1995
+ this.defaultFn = config.defaultFn;
1996
+ this.onUpdateFn = config.onUpdateFn;
1997
+ this.hasDefault = config.hasDefault;
1998
+ this.primary = config.primaryKey;
1999
+ this.isUnique = config.isUnique;
2000
+ this.uniqueName = config.uniqueName;
2001
+ this.uniqueType = config.uniqueType;
2002
+ this.dataType = config.dataType;
2003
+ this.columnType = config.columnType;
2004
+ this.generated = config.generated;
2005
+ this.generatedIdentity = config.generatedIdentity;
2006
+ this.length = config["length"];
2007
+ this.isLengthExact = config["isLengthExact"];
2008
+ }
2009
+ mapFromDriverValue = noop;
2010
+ mapToDriverValue = noop;
2011
+ /** @internal */
2012
+ postBuild() {
2013
+ return this;
2014
+ }
2015
+ /** @internal */
2016
+ shouldDisableInsert() {
2017
+ return this.config.generated !== void 0 && this.config.generated.type !== "byDefault";
2018
+ }
2019
+ /** @internal */
2020
+ [OriginalColumn]() {
2021
+ return this;
2022
+ }
2023
+ };
2024
+ // ../../node_modules/.bun/drizzle-orm@1.0.0-rc.6+de0f8d2b751ff1e4/node_modules/drizzle-orm/sql/common-chunks.js
2025
+ var StringChunk = class {
2026
+ value;
2027
+ static [entityKind] = "StringChunk";
2028
+ static [Symbol.hasInstance](value) {
2029
+ return is(value, this);
2030
+ }
2031
+ constructor(value) {
2032
+ this.value = value;
2033
+ }
2034
+ };
2035
+ /** Shared string chunks, keyed by their values */
2036
+ const commonStringChunks = {
2037
+ ", ": new StringChunk(", "),
2038
+ " ": new StringChunk(" "),
2039
+ "(": new StringChunk("("),
2040
+ ")": new StringChunk(")"),
2041
+ "((": new StringChunk("(("),
2042
+ "))": new StringChunk("))"),
2043
+ "), (": new StringChunk("), ("),
2044
+ ".": new StringChunk("."),
2045
+ default: new StringChunk("default"),
2046
+ null: new StringChunk("null"),
2047
+ "1 = 0": new StringChunk("1 = 0"),
2048
+ "1 = 1": new StringChunk("1 = 1"),
2049
+ " = ": new StringChunk(" = "),
2050
+ " <> ": new StringChunk(" <> "),
2051
+ " > ": new StringChunk(" > "),
2052
+ " >= ": new StringChunk(" >= "),
2053
+ " < ": new StringChunk(" < "),
2054
+ " <= ": new StringChunk(" <= "),
2055
+ " in ": new StringChunk(" in "),
2056
+ " not in ": new StringChunk(" not in "),
2057
+ ") and (": new StringChunk(") and ("),
2058
+ ") or (": new StringChunk(") or ("),
2059
+ "not (": new StringChunk("not ("),
2060
+ "with ": new StringChunk("with "),
2061
+ "select ": new StringChunk("select "),
2062
+ "(select ": new StringChunk("(select "),
2063
+ "values ": new StringChunk("values "),
2064
+ " from ": new StringChunk(" from "),
2065
+ ".* from ": new StringChunk(".* from "),
2066
+ " as ": new StringChunk(" as "),
2067
+ ") as ": new StringChunk(") as "),
2068
+ " inner join ": new StringChunk(" inner join "),
2069
+ " cross join ": new StringChunk(" cross join "),
2070
+ " on ": new StringChunk(" on "),
2071
+ " where ": new StringChunk(" where "),
2072
+ " order by ": new StringChunk(" order by "),
2073
+ " asc": new StringChunk(" asc"),
2074
+ " desc": new StringChunk(" desc"),
2075
+ " limit ": new StringChunk(" limit "),
2076
+ " limit 1": new StringChunk(" limit 1"),
2077
+ " offset ": new StringChunk(" offset "),
2078
+ "top(1) ": new StringChunk("top(1) "),
2079
+ "exists (select * from ": new StringChunk("exists (select * from "),
2080
+ "not exists (select * from ": new StringChunk("not exists (select * from "),
2081
+ "select count(*) as ": new StringChunk("select count(*) as "),
2082
+ "(select count(*) from ": new StringChunk("(select count(*) from "),
2083
+ "min(": new StringChunk("min("),
2084
+ "max(": new StringChunk("max("),
2085
+ "count(": new StringChunk("count("),
2086
+ "avg(": new StringChunk("avg("),
2087
+ "first(": new StringChunk("first(")
2088
+ };
2089
+ // ../../node_modules/.bun/drizzle-orm@1.0.0-rc.6+de0f8d2b751ff1e4/node_modules/drizzle-orm/table.utils.js
2090
+ /** @internal */
2091
+ const TableName = Symbol.for("drizzle:Name");
2092
+ /** @internal */
2093
+ const TableSchema = Symbol.for("drizzle:Schema");
2094
+ /** @internal */
2095
+ const TableColumns = Symbol.for("drizzle:Columns");
2096
+ /** @internal */
2097
+ const ExtraConfigColumns = Symbol.for("drizzle:ExtraConfigColumns");
2098
+ /** @internal */
2099
+ const OriginalName = Symbol.for("drizzle:OriginalName");
2100
+ /** @internal */
2101
+ const BaseName = Symbol.for("drizzle:BaseName");
2102
+ /** @internal */
2103
+ const IsAlias = Symbol.for("drizzle:IsAlias");
2104
+ /** @internal */
2105
+ const Qualifier = Symbol.for("drizzle:Qualifier");
2106
+ /** @internal */
2107
+ const ExtraConfigBuilder = Symbol.for("drizzle:ExtraConfigBuilder");
2108
+ // ../../node_modules/.bun/drizzle-orm@1.0.0-rc.6+de0f8d2b751ff1e4/node_modules/drizzle-orm/table.js
2109
+ const IsDrizzleTable = Symbol.for("drizzle:IsDrizzleTable");
2110
+ var Table = class {
2111
+ static [entityKind] = "Table";
2112
+ static [Symbol.hasInstance](value) {
2113
+ return is(value, this);
2114
+ }
2115
+ /** @internal */
2116
+ static Symbol = {
2117
+ Name: TableName,
2118
+ Schema: TableSchema,
2119
+ OriginalName,
2120
+ Columns: TableColumns,
2121
+ ExtraConfigColumns,
2122
+ BaseName,
2123
+ IsAlias,
2124
+ ExtraConfigBuilder
2125
+ };
2126
+ /**
2127
+ * @internal
2128
+ * Can be changed if the table is aliased.
2129
+ */
2130
+ [TableName];
2131
+ /**
2132
+ * @internal
2133
+ * Used to store the original name of the table, before any aliasing.
2134
+ */
2135
+ [OriginalName];
2136
+ /** @internal */
2137
+ [TableSchema];
2138
+ /** @internal */
2139
+ [TableColumns];
2140
+ /** @internal */
2141
+ [ExtraConfigColumns];
2142
+ /**
2143
+ * @internal
2144
+ * Used to store the table name before the transformation via the `tableCreator` functions.
2145
+ */
2146
+ [BaseName];
2147
+ /** @internal */
2148
+ [IsAlias] = false;
2149
+ /** @internal */
2150
+ [IsDrizzleTable] = true;
2151
+ /** @internal */
2152
+ [ExtraConfigBuilder] = void 0;
2153
+ constructor(name, schema, baseName) {
2154
+ this[TableName] = this[OriginalName] = name;
2155
+ this[TableSchema] = schema;
2156
+ this[BaseName] = baseName;
2157
+ }
2158
+ };
2159
+ function getTableName(table) {
2160
+ return table[TableName];
2161
+ }
2162
+ // ../../node_modules/.bun/drizzle-orm@1.0.0-rc.6+de0f8d2b751ff1e4/node_modules/drizzle-orm/subquery.js
2163
+ var Subquery = class {
2164
+ static [entityKind] = "Subquery";
2165
+ static [Symbol.hasInstance](value) {
2166
+ return is(value, this);
2167
+ }
2168
+ /** @internal */
2169
+ get [TableName]() {
2170
+ return this._.alias;
2171
+ }
2172
+ /** @internal */
2173
+ get [TableSchema]() {}
2174
+ /** @internal */
2175
+ get [OriginalName]() {
2176
+ return this._.alias;
2177
+ }
2178
+ /** @internal */
2179
+ get [IsAlias]() {
2180
+ return false;
2181
+ }
2182
+ /** @internal */
2183
+ get [TableColumns]() {
2184
+ return this._.selectedFields;
2185
+ }
2186
+ constructor(sql, fields, alias, isWith = false) {
2187
+ this._ = {
2188
+ brand: "Subquery",
2189
+ sql,
2190
+ selectedFields: fields,
2191
+ alias,
2192
+ isWith
2193
+ };
2194
+ }
2195
+ };
2196
+ // ../../node_modules/.bun/drizzle-orm@1.0.0-rc.6+de0f8d2b751ff1e4/node_modules/drizzle-orm/view-common.js
2197
+ const ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig");
2198
+ // ../../node_modules/.bun/drizzle-orm@1.0.0-rc.6+de0f8d2b751ff1e4/node_modules/drizzle-orm/view.js
2199
+ const IsDrizzleView = Symbol.for("drizzle:IsDrizzleView");
2200
+ var View = class {
2201
+ static [entityKind] = "View";
2202
+ static [Symbol.hasInstance](value) {
2203
+ return is(value, this);
2204
+ }
2205
+ /** @internal */
2206
+ [ViewBaseConfig];
2207
+ /** @internal */
2208
+ [IsDrizzleView] = true;
2209
+ /** @internal */
2210
+ get [TableName]() {
2211
+ return this[ViewBaseConfig].name;
2212
+ }
2213
+ /** @internal */
2214
+ get [TableSchema]() {
2215
+ return this[ViewBaseConfig].schema;
2216
+ }
2217
+ /** @internal */
2218
+ get [IsAlias]() {
2219
+ return this[ViewBaseConfig].isAlias;
2220
+ }
2221
+ /** @internal */
2222
+ get [OriginalName]() {
2223
+ return this[ViewBaseConfig].originalName;
2224
+ }
2225
+ /** @internal */
2226
+ get [TableColumns]() {
2227
+ return this[ViewBaseConfig].selectedFields;
2228
+ }
2229
+ constructor({ name, schema, selectedFields, query }) {
2230
+ this[ViewBaseConfig] = {
2231
+ name,
2232
+ originalName: name,
2233
+ schema,
2234
+ selectedFields,
2235
+ query,
2236
+ isExisting: !query,
2237
+ isAlias: false
2238
+ };
2239
+ }
2240
+ };
2241
+ // ../../node_modules/.bun/drizzle-orm@1.0.0-rc.6+de0f8d2b751ff1e4/node_modules/drizzle-orm/sql/sql.js
2242
+ function isSQLWrapper(value) {
2243
+ return value !== null && value !== void 0 && typeof value.getSQL === "function";
2244
+ }
2245
+ var SQL = class SQL {
2246
+ queryChunks;
2247
+ static [entityKind] = "SQL";
2248
+ static [Symbol.hasInstance](value) {
2249
+ return is(value, this);
2250
+ }
2251
+ /** @internal */
2252
+ decoder = noopDecoder;
2253
+ /** @internal */
2254
+ shouldInlineParams = false;
2255
+ constructor(queryChunks) {
2256
+ this.queryChunks = queryChunks;
2257
+ }
2258
+ append(query) {
2259
+ this.queryChunks.push(...query.queryChunks);
2260
+ return this;
2261
+ }
2262
+ toQuery(config) {
2263
+ return this.buildQueryFromSourceParams(this.queryChunks, config);
2264
+ }
2265
+ buildQueryFromSourceParams(chunks, _config) {
2266
+ const out = { sql: "" };
2267
+ const params = [];
2268
+ const bounds = _config.tagged ? [] : void 0;
2269
+ this.collectSQL(chunks, _config, _config.paramStartIndex || { value: 0 }, _config.inlineParams || this.shouldInlineParams, out, params, bounds);
2270
+ const query = out.sql;
2271
+ if (bounds === void 0) return {
2272
+ sql: query,
2273
+ params
2274
+ };
2275
+ const segments = new Array(bounds.length);
2276
+ for (let i = 0; i < bounds.length; ++i) segments[i] = query.slice(bounds[i], i + 1 < bounds.length ? bounds[i + 1] : query.length);
2277
+ return {
2278
+ sql: query,
2279
+ params,
2280
+ _sql: Object.assign(segments, { raw: segments })
2281
+ };
2282
+ }
2283
+ collectSQL(chunks, config, paramStartIndex, inlineParams, out, params, bounds) {
2284
+ const { escapeName, escapeParam, codecs, invokeSource } = config;
2285
+ for (let i = 0; i < chunks.length; ++i) {
2286
+ if (bounds !== void 0) bounds.push(out.sql.length);
2287
+ const chunk = chunks[i];
2288
+ const kind = chunkKindOf(chunk);
2289
+ if (isChunk(chunk, kind, chunkKinds.string)) {
2290
+ out.sql += chunk.value ?? "";
2291
+ continue;
2292
+ }
2293
+ if (isChunk(chunk, kind, chunkKinds.sql)) {
2294
+ this.collectSQL(chunk.queryChunks, config, paramStartIndex, inlineParams || chunk.shouldInlineParams, out, params, void 0);
2295
+ continue;
2296
+ }
2297
+ if (isChunk(chunk, kind, chunkKinds.name)) {
2298
+ out.sql += escapeName(chunk.value);
2299
+ continue;
2300
+ }
2301
+ if (chunk === void 0) continue;
2302
+ if (isChunk(chunk, kind, chunkKinds.column)) {
2303
+ const columnName = chunk.name;
2304
+ if (invokeSource === "indexes") {
2305
+ out.sql += escapeName(columnName);
2306
+ continue;
2307
+ }
2308
+ const schemaName = invokeSource === "mssql-check" ? void 0 : chunk.table[Table.Symbol.Schema];
2309
+ out.sql += chunk.isAlias ? escapeName(chunk.name) : chunk.table[IsAlias] || schemaName === void 0 ? escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(columnName) : escapeName(schemaName) + "." + escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(columnName);
2310
+ continue;
2311
+ }
2312
+ if (isChunk(chunk, kind, chunkKinds.param)) {
2313
+ const paramValue = chunk.value;
2314
+ const valueKind = chunkKindOf(paramValue);
2315
+ if (isChunk(paramValue, valueKind, chunkKinds.sql)) {
2316
+ const nested = paramValue;
2317
+ this.collectSQL(nested.queryChunks, config, paramStartIndex, inlineParams || nested.shouldInlineParams, out, params, void 0);
2318
+ continue;
2319
+ }
2320
+ const encoder = chunk.encoder;
2321
+ const paramCodecs = codecs && chunkKindOf(encoder) === chunkKinds.column ? codecs.codecsOf(encoder) : void 0;
2322
+ if (valueKind === chunkKinds.placeholder) {
2323
+ const escaped = escapeParam(paramStartIndex.value++, chunk);
2324
+ const normalize = paramCodecs?.normalizeParam;
2325
+ const cast = paramCodecs?.castParam;
2326
+ chunk.codec = normalize ? (value) => normalize(value, encoder.dimensions) : void 0;
2327
+ out.sql += cast ? cast(escaped, encoder, encoder.dimensions) : escaped;
2328
+ params.push(chunk);
2329
+ continue;
2330
+ }
2331
+ this.collectBoundValue(paramValue, encoder, paramCodecs, config, paramStartIndex, inlineParams, out, params);
2332
+ continue;
2333
+ }
2334
+ if (isChunk(chunk, kind, chunkKinds.placeholder)) {
2335
+ out.sql += escapeParam(paramStartIndex.value++, chunk);
2336
+ params.push(chunk);
2337
+ continue;
2338
+ }
2339
+ if (isChunk(chunk, kind, chunkKinds.table)) {
2340
+ const schemaName = chunk[Table.Symbol.Schema];
2341
+ const tableName = chunk[Table.Symbol.Name];
2342
+ if (invokeSource === "mssql-view-with-schemabinding") {
2343
+ out.sql += (schemaName === void 0 ? escapeName("dbo") : escapeName(schemaName)) + "." + escapeName(tableName);
2344
+ continue;
2345
+ }
2346
+ out.sql += schemaName === void 0 || chunk[IsAlias] ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName);
2347
+ continue;
2348
+ }
2349
+ if (isChunk(chunk, kind, chunkKinds.view)) {
2350
+ const schemaName = chunk[ViewBaseConfig].schema;
2351
+ const viewName = chunk[ViewBaseConfig].name;
2352
+ out.sql += schemaName === void 0 || chunk[ViewBaseConfig].isAlias ? escapeName(viewName) : escapeName(schemaName) + "." + escapeName(viewName);
2353
+ continue;
2354
+ }
2355
+ if (isChunk(chunk, kind, chunkKinds.aliased) && chunk.fieldAlias !== void 0) {
2356
+ out.sql += (chunk.origin !== void 0 ? escapeName(chunk.origin) + "." : "") + escapeName(chunk.fieldAlias);
2357
+ continue;
2358
+ }
2359
+ if (isChunk(chunk, kind, chunkKinds.valueRows)) {
2360
+ const { cells, encoders } = chunk;
2361
+ const width = encoders.length;
2362
+ const paramCodecs = new Array(width);
2363
+ for (let j = 0; j < width; ++j) {
2364
+ const encoder = encoders[j];
2365
+ paramCodecs[j] = codecs && chunkKindOf(encoder) === chunkKinds.column ? codecs.codecsOf(encoder) : void 0;
2366
+ }
2367
+ out.sql += "(";
2368
+ for (let j = 0, column = 0; j < cells.length; ++j, ++column) {
2369
+ if (column === width) {
2370
+ column = 0;
2371
+ out.sql += "), (";
2372
+ } else if (column > 0) out.sql += ", ";
2373
+ const cell = cells[j];
2374
+ const cellKind = chunkKindOf(cell);
2375
+ if (cellKind === chunkKinds.other) {
2376
+ this.collectBoundValue(cell, encoders[column], paramCodecs[column], config, paramStartIndex, inlineParams, out, params);
2377
+ continue;
2378
+ }
2379
+ if (isChunk(cell, cellKind, chunkKinds.string)) {
2380
+ out.sql += cell.value ?? "";
2381
+ continue;
2382
+ }
2383
+ this.collectSQL([cellKind === chunkKinds.sql ? cell : new Param(cell, encoders[column])], config, paramStartIndex, inlineParams, out, params, void 0);
2384
+ }
2385
+ out.sql += ")";
2386
+ continue;
2387
+ }
2388
+ if (isChunk(chunk, kind, chunkKinds.subquery)) {
2389
+ if (chunk._.isWith) {
2390
+ out.sql += escapeName(chunk._.alias);
2391
+ continue;
2392
+ }
2393
+ const nested = chunk._.sql;
2394
+ out.sql += "(";
2395
+ this.collectSQL(nested.queryChunks, config, paramStartIndex, inlineParams || nested.shouldInlineParams, out, params, void 0);
2396
+ out.sql += ") " + escapeName(chunk._.alias);
2397
+ continue;
2398
+ }
2399
+ if (typeof chunk === "function" && "enumName" in chunk) {
2400
+ if ("schema" in chunk && chunk.schema) {
2401
+ out.sql += escapeName(chunk.schema) + "." + escapeName(chunk.enumName);
2402
+ continue;
2403
+ }
2404
+ out.sql += escapeName(chunk.enumName);
2405
+ continue;
2406
+ }
2407
+ if (isSQLWrapper(chunk)) {
2408
+ const nested = chunk.getSQL();
2409
+ const nestedInlineParams = inlineParams || nested.shouldInlineParams;
2410
+ if (chunk.shouldOmitSQLParens?.()) {
2411
+ this.collectSQL(nested.queryChunks, config, paramStartIndex, nestedInlineParams, out, params, void 0);
2412
+ continue;
2413
+ }
2414
+ out.sql += "(";
2415
+ this.collectSQL(nested.queryChunks, config, paramStartIndex, nestedInlineParams, out, params, void 0);
2416
+ out.sql += ")";
2417
+ continue;
2418
+ }
2419
+ if (Array.isArray(chunk)) {
2420
+ out.sql += "(";
2421
+ const element = [void 0];
2422
+ for (let j = 0; j < chunk.length; ++j) {
2423
+ if (j > 0) out.sql += ", ";
2424
+ element[0] = chunk[j];
2425
+ this.collectSQL(element, config, paramStartIndex, inlineParams, out, params, void 0);
2426
+ }
2427
+ out.sql += ")";
2428
+ continue;
2429
+ }
2430
+ if (inlineParams) {
2431
+ out.sql += this.mapInlineParam(chunk, config);
2432
+ continue;
2433
+ }
2434
+ out.sql += escapeParam(paramStartIndex.value++, chunk);
2435
+ params.push(chunk);
2436
+ }
2437
+ }
2438
+ collectBoundValue(value, encoder, paramCodecs, config, paramStartIndex, inlineParams, out, params) {
2439
+ let mappedValue = value;
2440
+ if (value !== null) {
2441
+ if (!encoder.mapToDriverValue.isNoop) mappedValue = encoder.mapToDriverValue(value);
2442
+ if (chunkKindOf(mappedValue) === chunkKinds.sql) {
2443
+ const nested = mappedValue;
2444
+ this.collectSQL(nested.queryChunks, config, paramStartIndex, inlineParams || nested.shouldInlineParams, out, params, void 0);
2445
+ return;
2446
+ }
2447
+ const normalize = paramCodecs?.normalizeParam;
2448
+ if (!inlineParams && normalize) mappedValue = normalize(mappedValue, encoder.dimensions);
2449
+ }
2450
+ if (inlineParams) {
2451
+ out.sql += this.mapInlineParam(mappedValue, config);
2452
+ return;
2453
+ }
2454
+ const { escapeParam } = config;
2455
+ const escaped = escapeParam(paramStartIndex.value++, mappedValue);
2456
+ const cast = paramCodecs?.castParam;
2457
+ out.sql += cast ? cast(escaped, encoder, encoder.dimensions) : escaped;
2458
+ params.push(mappedValue);
2459
+ }
2460
+ mapInlineParam(chunk, { escapeString }) {
2461
+ if (chunk === null) return "null";
2462
+ if (typeof chunk === "number" || typeof chunk === "boolean" || typeof chunk === "bigint") return chunk.toString();
2463
+ if (typeof chunk === "string") return escapeString(chunk);
2464
+ if (typeof chunk === "object") {
2465
+ const mappedValueAsString = chunk.toString();
2466
+ if (mappedValueAsString === "[object Object]") return escapeString(JSON.stringify(chunk));
2467
+ return escapeString(mappedValueAsString);
2468
+ }
2469
+ throw new Error("Unexpected param value: " + chunk);
2470
+ }
2471
+ getSQL() {
2472
+ return this;
2473
+ }
2474
+ as(alias) {
2475
+ if (alias === void 0) return this;
2476
+ return new SQL.Aliased(this, alias);
2477
+ }
2478
+ mapWith(decoder) {
2479
+ this.decoder = typeof decoder === "function" ? { mapFromDriverValue: decoder } : decoder;
2480
+ return this;
2481
+ }
2482
+ nullable() {
2483
+ return this;
2484
+ }
2485
+ inlineParams() {
2486
+ this.shouldInlineParams = true;
2487
+ return this;
2488
+ }
2489
+ /**
2490
+ * This method is used to conditionally include a part of the query.
2491
+ *
2492
+ * @param condition - Condition to check
2493
+ * @returns itself if the condition is `true`, otherwise `undefined`
2494
+ */
2495
+ if(condition) {
2496
+ return condition ? this : void 0;
2497
+ }
2498
+ };
2499
+ /**
2500
+ * Ids of the chunk classes `chunkKindOf` tells apart
2501
+ */
2502
+ const chunkKinds = {
2503
+ other: 0,
2504
+ string: 1,
2505
+ sql: 2,
2506
+ name: 3,
2507
+ column: 4,
2508
+ param: 5,
2509
+ placeholder: 6,
2510
+ table: 7,
2511
+ view: 8,
2512
+ aliased: 9,
2513
+ subquery: 10,
2514
+ valueRows: 11
2515
+ };
2516
+ const chunkKindByConstructor = /* @__PURE__ */ new WeakMap();
2517
+ const chunkKindKey = Symbol("drizzle:chunkKind");
2518
+ function resolveChunkKind(ctor, kinds) {
2519
+ const kind = kinds.has(StringChunk[entityKind]) ? chunkKinds.string : kinds.has(SQL[entityKind]) ? chunkKinds.sql : kinds.has(Name[entityKind]) ? chunkKinds.name : kinds.has(Column[entityKind]) ? chunkKinds.column : kinds.has(Param[entityKind]) ? chunkKinds.param : kinds.has(Placeholder[entityKind]) ? chunkKinds.placeholder : kinds.has(Table[entityKind]) ? chunkKinds.table : kinds.has(View[entityKind]) ? chunkKinds.view : kinds.has(SQL.Aliased[entityKind]) ? chunkKinds.aliased : kinds.has(Subquery[entityKind]) ? chunkKinds.subquery : kinds.has(ValueRows[entityKind]) ? chunkKinds.valueRows : chunkKinds.other;
2520
+ chunkKindByConstructor.set(ctor, kind);
2521
+ if (kind !== chunkKinds.other) Object.defineProperty(ctor.prototype, chunkKindKey, { value: kind });
2522
+ return kind;
2523
+ }
2524
+ function chunkKindOf(chunk) {
2525
+ if (chunk === null || typeof chunk !== "object") return chunkKinds.other;
2526
+ const cached = chunk[chunkKindKey];
2527
+ if (cached !== void 0) return cached;
2528
+ const ctor = Object.getPrototypeOf(chunk)?.constructor;
2529
+ if (typeof ctor !== "function") return chunkKinds.other;
2530
+ return chunkKindByConstructor.get(ctor) ?? resolveChunkKind(ctor, entityKindsOf(chunk));
2531
+ }
2532
+ function isChunk(_chunk, kind, expected) {
2533
+ return kind === expected;
2534
+ }
2535
+ /**
2536
+ * Any DB name (table, column, index etc.)
2537
+ */
2538
+ var Name = class {
2539
+ value;
2540
+ static [entityKind] = "Name";
2541
+ static [Symbol.hasInstance](value) {
2542
+ return is(value, this);
2543
+ }
2544
+ brand;
2545
+ constructor(value) {
2546
+ this.value = value;
2547
+ }
2548
+ getSQL() {
2549
+ return new SQL([this]);
2550
+ }
2551
+ };
2552
+ const noopDecoder = { mapFromDriverValue: (value) => value };
2553
+ noopDecoder.mapFromDriverValue.isNoop = true;
2554
+ const noopEncoder = { mapToDriverValue: (value) => value };
2555
+ noopEncoder.mapToDriverValue.isNoop = true;
2556
+ ({
2557
+ ...noopDecoder,
2558
+ ...noopEncoder
2559
+ });
2560
+ /** Parameter value that is optionally bound to an encoder (for example, a column). */
2561
+ var Param = class {
2562
+ value;
2563
+ encoder;
2564
+ codec;
2565
+ static [entityKind] = "Param";
2566
+ static [Symbol.hasInstance](value) {
2567
+ return is(value, this);
2568
+ }
2569
+ brand;
2570
+ /**
2571
+ * @param value - Parameter value
2572
+ * @param encoder - Encoder to convert the value to a driver parameter
2573
+ */
2574
+ constructor(value, encoder = noopEncoder, codec) {
2575
+ this.value = value;
2576
+ this.encoder = encoder;
2577
+ this.codec = codec;
2578
+ }
2579
+ getSQL() {
2580
+ return new SQL([this]);
2581
+ }
2582
+ };
2583
+ var ValueRows = class {
2584
+ cells;
2585
+ encoders;
2586
+ static [entityKind] = "ValueRows";
2587
+ static [Symbol.hasInstance](value) {
2588
+ return is(value, this);
2589
+ }
2590
+ constructor(cells, encoders) {
2591
+ this.cells = cells;
2592
+ this.encoders = encoders;
2593
+ }
2594
+ getSQL() {
2595
+ const { cells, encoders } = this;
2596
+ const width = encoders.length;
2597
+ const chunks = [];
2598
+ for (let i = 0; i < cells.length; ++i) {
2599
+ const column = i % width;
2600
+ chunks.push(column === 0 ? i === 0 ? commonStringChunks["("] : commonStringChunks["), ("] : commonStringChunks[", "]);
2601
+ const cell = cells[i];
2602
+ const kind = chunkKindOf(cell);
2603
+ chunks.push(kind === chunkKinds.sql || kind === chunkKinds.string ? cell : new Param(cell, encoders[column]));
2604
+ }
2605
+ chunks.push(commonStringChunks[")"]);
2606
+ return new SQL(chunks);
2607
+ }
2608
+ shouldOmitSQLParens() {
2609
+ return true;
2610
+ }
2611
+ };
2612
+ function sql(strings, ...params) {
2613
+ const queryChunks = [];
2614
+ if (strings[0]) queryChunks.push(new StringChunk(strings[0]));
2615
+ for (let paramIdx = 0; paramIdx < params.length; ++paramIdx) {
2616
+ const param = params[paramIdx];
2617
+ if (param !== void 0) queryChunks.push(param);
2618
+ const string = strings[paramIdx + 1];
2619
+ if (string) queryChunks.push(new StringChunk(string));
2620
+ }
2621
+ return new SQL(queryChunks);
2622
+ }
2623
+ (function(_sql) {
2624
+ function empty() {
2625
+ return new SQL([]);
2626
+ }
2627
+ _sql.empty = empty;
2628
+ function fromList(list) {
2629
+ return new SQL(list);
2630
+ }
2631
+ _sql.fromList = fromList;
2632
+ function raw(str) {
2633
+ return new SQL([new StringChunk(str)]);
2634
+ }
2635
+ _sql.raw = raw;
2636
+ function join(chunks, separator) {
2637
+ const { length } = chunks;
2638
+ if (separator === void 0 || length === 0) return new SQL(chunks.slice());
2639
+ const result = new Array(length * 2 - 1);
2640
+ for (let i = 0, writeIdx = 0; i < length; ++i) {
2641
+ result[writeIdx++] = chunks[i];
2642
+ if (i < length - 1) result[writeIdx++] = separator;
2643
+ }
2644
+ return new SQL(result);
2645
+ }
2646
+ _sql.join = join;
2647
+ function identifier(value) {
2648
+ return new Name(value);
2649
+ }
2650
+ _sql.identifier = identifier;
2651
+ function placeholder(name) {
2652
+ return new Placeholder(name);
2653
+ }
2654
+ _sql.placeholder = placeholder;
2655
+ function param(value, encoder) {
2656
+ return new Param(value, encoder);
2657
+ }
2658
+ _sql.param = param;
2659
+ function comment(input) {
2660
+ const encoded = sqlCommenter(input);
2661
+ if (!encoded.length) return void 0;
2662
+ return sql.raw(encoded);
2663
+ }
2664
+ _sql.comment = comment;
2665
+ })(sql || (sql = {}));
2666
+ function sqlCommenter(input) {
2667
+ const encoded = sqlCommenter.encodeInput(input);
2668
+ if (!encoded.length) return "";
2669
+ return `/*${encoded}*/`;
2670
+ }
2671
+ (function(_sqlCommenter) {
2672
+ function merge(input1, input2) {
2673
+ let encoded;
2674
+ if (typeof input1 === "object" && typeof input2 === "object") encoded = encodeInput({
2675
+ ...input1,
2676
+ ...input2
2677
+ });
2678
+ else if (input1 && input2) encoded = [encodeInput(input1), encodeInput(input2)].filter((i) => i.length).join(",");
2679
+ else if (input2) encoded = encodeInput(input2);
2680
+ else if (input1) encoded = encodeInput(input1);
2681
+ else return "";
2682
+ if (!encoded.length) return "";
2683
+ return `/*${encoded}*/`;
2684
+ }
2685
+ _sqlCommenter.merge = merge;
2686
+ function encodeInput(input) {
2687
+ if (typeof input === "string") {
2688
+ if (!input.length) return input;
2689
+ return sanitizeStringInput(input);
2690
+ }
2691
+ const parts = [];
2692
+ for (const [key, value] of Object.entries(input)) {
2693
+ if (value === null || value === void 0 || value === "") continue;
2694
+ const encodedKey = sanitizeObjectElement(key);
2695
+ const encodedValue = sanitizeObjectElement(String(value));
2696
+ parts.push(`${encodedKey}='${encodedValue}'`);
2697
+ }
2698
+ if (!parts.length) return "";
2699
+ return parts.sort().join(",");
2700
+ }
2701
+ _sqlCommenter.encodeInput = encodeInput;
2702
+ function sanitizeObjectElement(key) {
2703
+ return encodeURIComponent(key).replace(/'/g, `\\'`);
2704
+ }
2705
+ _sqlCommenter.sanitizeObjectElement = sanitizeObjectElement;
2706
+ function sanitizeStringInput(input) {
2707
+ return input.replace(/\/\*/g, "/ *").replace(/\*\//g, "* /");
2708
+ }
2709
+ _sqlCommenter.sanitizeStringInput = sanitizeStringInput;
2710
+ })(sqlCommenter || (sqlCommenter = {}));
2711
+ (function(_SQL) {
2712
+ class Aliased {
2713
+ sql;
2714
+ fieldAlias;
2715
+ static [entityKind] = "SQL.Aliased";
2716
+ static [Symbol.hasInstance](value) {
2717
+ return is(value, this);
2718
+ }
2719
+ /** @internal */
2720
+ isSelectionField = false;
2721
+ /** @internal */
2722
+ origin;
2723
+ constructor(sql, fieldAlias) {
2724
+ this.sql = sql;
2725
+ this.fieldAlias = fieldAlias;
2726
+ }
2727
+ getSQL() {
2728
+ return this.sql;
2729
+ }
2730
+ /** @internal */
2731
+ clone() {
2732
+ return new Aliased(this.sql, this.fieldAlias);
2733
+ }
2734
+ }
2735
+ _SQL.Aliased = Aliased;
2736
+ })(SQL || (SQL = {}));
2737
+ var Placeholder = class {
2738
+ name;
2739
+ static [entityKind] = "Placeholder";
2740
+ static [Symbol.hasInstance](value) {
2741
+ return is(value, this);
2742
+ }
2743
+ constructor(name) {
2744
+ this.name = name;
2745
+ }
2746
+ /**
2747
+ * @deprecated Field hidden to prevent bleeding into autocomplete
2748
+ */
2749
+ getSQL() {
2750
+ return new SQL([this]);
2751
+ }
2752
+ };
2753
+ Column.prototype.getSQL = function() {
2754
+ return new SQL([this]);
2755
+ };
2756
+ StringChunk.prototype.getSQL = function() {
2757
+ return new SQL([this]);
2758
+ };
2759
+ Subquery.prototype.getSQL = function() {
2760
+ return new SQL([this]);
2761
+ };
2762
+ function defineQualifier(prototype, build) {
2763
+ Object.defineProperty(prototype, Qualifier, {
2764
+ get() {
2765
+ const value = build(this);
2766
+ Object.defineProperty(this, Qualifier, {
2767
+ value,
2768
+ enumerable: false,
2769
+ configurable: true,
2770
+ writable: true
2771
+ });
2772
+ return value;
2773
+ },
2774
+ configurable: true
2775
+ });
2776
+ }
2777
+ function qualifiedName(schema, name) {
2778
+ return new SQL(schema === void 0 ? [new Name(name)] : [
2779
+ new Name(schema),
2780
+ commonStringChunks["."],
2781
+ new Name(name)
2782
+ ]);
2783
+ }
2784
+ defineQualifier(Table.prototype, (table) => qualifiedName(table[TableSchema], table[TableName]));
2785
+ defineQualifier(View.prototype, (view) => qualifiedName(view[ViewBaseConfig].schema, view[ViewBaseConfig].name));
2786
+ defineQualifier(Subquery.prototype, (subquery) => new Name(subquery._.alias));
2787
+ Object.getPrototypeOf(() => null).constructor;
2788
+ typeof TextDecoder === "function" && new TextDecoder();
2789
+ // ../../node_modules/.bun/drizzle-orm@1.0.0-rc.6+de0f8d2b751ff1e4/node_modules/drizzle-orm/sqlite-core/table.js
2790
+ /** @internal */
2791
+ const InlineForeignKeys = Symbol.for("drizzle:SQLiteInlineForeignKeys");
2792
+ var SQLiteTable = class extends Table {
2793
+ static [entityKind] = "SQLiteTable";
2794
+ /** @internal */
2795
+ static Symbol = Object.assign({}, Table.Symbol, { InlineForeignKeys });
2796
+ /** @internal */
2797
+ [Table.Symbol.Columns];
2798
+ /** @internal */
2799
+ [InlineForeignKeys] = [];
2800
+ /** @internal */
2801
+ [Table.Symbol.ExtraConfigBuilder] = void 0;
2802
+ };
1925
2803
  // ../process/src/lib/list.ts
2804
+ const drizzleBaseTableName = Symbol.for("drizzle:BaseName");
2805
+ function watchedTableNames(table) {
2806
+ if (!is(table, SQLiteTable)) throw new Error("List watchTables requires Drizzle SQLite tables");
2807
+ const baseName = Reflect.get(table, drizzleBaseTableName);
2808
+ return [typeof baseName === "string" ? baseName : getTableName(table)];
2809
+ }
2810
+ /** Runtime adapter for explicitly marked raw writes. */
2811
+ var RawSqlWriteTracking = class extends Context.Service()("processfocus/RawSqlWriteTracking") {};
2812
+ /**
2813
+ * Run one raw write using the supplied runtime SQL client and mark its table
2814
+ * for watched List refresh. Mark inside `SqlClient.withTransaction` to defer
2815
+ * refresh until the outer commit. Handle statement errors outside this call.
2816
+ *
2817
+ * @example
2818
+ * yield* markRawSqlWrite(orders, (sql) =>
2819
+ * sql`UPDATE orders SET status = ${status} WHERE id = ${id}`,
2820
+ * )
2821
+ */
2822
+ function markRawSqlWrite(table, write) {
2823
+ const tables = watchedTableNames(table);
2824
+ return Effect.gen(function* () {
2825
+ const client = yield* SqlClient;
2826
+ const result = yield* write(client);
2827
+ const tracking = yield* Effect.serviceOption(RawSqlWriteTracking);
2828
+ if (Option.isSome(tracking)) yield* tracking.value(client, tables);
2829
+ return result;
2830
+ });
2831
+ }
1926
2832
  /**
1927
2833
  * Error thrown when executeItemQuery is called on a List without an itemQuery defined.
1928
2834
  */
@@ -2077,6 +2983,7 @@ function assertExportFieldsHaveQuery(listPath, output, exportOutput, hasExportQu
2077
2983
  */
2078
2984
  var List = class extends Construct {
2079
2985
  isList = true;
2986
+ watchTableNames;
2080
2987
  _create;
2081
2988
  browser;
2082
2989
  createBrowser;
@@ -2122,6 +3029,7 @@ var List = class extends Construct {
2122
3029
  */
2123
3030
  constructor(scope, id, props) {
2124
3031
  super(scope, id);
3032
+ this.watchTableNames = props.watchTables?.flatMap(watchedTableNames) ?? [];
2125
3033
  this.browser = props.browser;
2126
3034
  this.createBrowser = props.create?.browser;
2127
3035
  this._create = props.create;
@@ -2716,6 +3624,7 @@ var Organisation = class extends OrgUnit {
2716
3624
  * Defines working hours, holidays, and special periods.
2717
3625
  */
2718
3626
  businessCalendar;
3627
+ /** @deprecated Export a plain `NotificationEmailLayer` from the project module instead. */
2719
3628
  notificationEmailLayer;
2720
3629
  constructor(props) {
2721
3630
  const timeZone = props.timeZone ?? "UTC";
@@ -3290,4 +4199,4 @@ Context.Service()("processfocus/process/LongDurationDispatcher");
3290
4199
  */
3291
4200
  var StepProcessStateReader = class extends Context.Service()("processfocus/process/StepProcessStateReader") {};
3292
4201
  Context.Service()("processfocus/process/SystemStepExecutor");
3293
- export { AppIcons, AppleOAuthProviderConfigSchema, AuthenticationConfig, CognitoOAuthProviderConfigSchema, CurrentStepJobContext, CustomEntitiesConfig, DEFAULT_OAUTH_PROVIDER_SCOPES, DEFAULT_PAGE_SIZE, DocumentStore, ElseBranch, ExecutionFailureNotifications, FlowPath, Form, GoogleOAuthProviderConfigSchema, Invitation, KeycloakOAuthProviderConfigSchema, List, ListSortable, ListUpdateValidationError, ListVisibleInList, LookupAccessor, LookupBuilder, LookupFieldNotFoundError, MAX_PAGE_SIZE, MicrosoftOAuthProviderConfigSchema, NodeStep, OAUTH_PROVIDER_NAMES, OAuthProviderConfigSchema, OAuthProviderNameSchema, OrgUnit, Organisation, PasskeyProviderConfigSchema, Phase, PoliciesConfig, Process, PublicFormBranding, Role, Schedule, SecretClientConfigSchema, Sla, SlackOAuthProviderConfigSchema, StatsView, Step, StepProcessStateReader, SystemStep, coerceAuthorTaggedError, isAuthenticationConfig, isAuthorTaggedError, isCustomEntitiesConfig, isDocumentStore, isForm, isInvitation, isList, isNonRetryableAuthorError, isOrgUnit, isOrganisation, isPoliciesConfig, isProcess, isRole, isStatsView, isStep };
4202
+ export { AppIcons, AppleOAuthProviderConfigSchema, AuthenticationConfig, CognitoOAuthProviderConfigSchema, CurrentStepJobContext, CustomEntitiesConfig, DEFAULT_OAUTH_PROVIDER_SCOPES, DEFAULT_PAGE_SIZE, DocumentStore, ElseBranch, ExecutionFailureNotifications, FlowPath, Form, GoogleOAuthProviderConfigSchema, Invitation, KeycloakOAuthProviderConfigSchema, List, ListSortable, ListUpdateValidationError, ListVisibleInList, LookupAccessor, LookupBuilder, LookupFieldNotFoundError, MAX_PAGE_SIZE, MicrosoftOAuthProviderConfigSchema, NodeStep, OAUTH_PROVIDER_NAMES, OAuthProviderConfigSchema, OAuthProviderNameSchema, OrgUnit, Organisation, PasskeyProviderConfigSchema, Phase, PoliciesConfig, Process, PublicFormBranding, Role, Schedule, SecretClientConfigSchema, Sla, SlackOAuthProviderConfigSchema, StatsView, Step, StepProcessStateReader, SystemStep, coerceAuthorTaggedError, isAuthenticationConfig, isAuthorTaggedError, isCustomEntitiesConfig, isDocumentStore, isForm, isInvitation, isList, isNonRetryableAuthorError, isOrgUnit, isOrganisation, isPoliciesConfig, isProcess, isRole, isStatsView, isStep, markRawSqlWrite };
@@ -1,11 +1,33 @@
1
1
  import { Construct } from "constructs";
2
2
  import type { Schema } from "effect";
3
- import { type Effect, Effect as EffectModule } from "effect";
3
+ import { Context, type Effect, Effect as EffectModule } from "effect";
4
+ import { SqlClient } from "effect/sql/SqlClient";
4
5
  import { type MetricBreakdownControl } from "../../../form-schema/src/index.js";
5
6
  import { type DeepWritable, type FlattenFields, type FlattenFieldsKeepingReadOnly, submissionSchemaSync as makeSubmissionSchema } from "../../../form-submission-schema/src/index.js";
6
7
  import type { OrgUnit } from "./org-unit.js";
7
8
  import type { Process } from "./process.js";
8
9
  import type { Role } from "./role.js";
10
+ type WatchedTable = {
11
+ readonly _: {
12
+ readonly brand: "Table";
13
+ readonly dialect: "sqlite";
14
+ };
15
+ };
16
+ declare const RawSqlWriteTracking_base: Context.ServiceClass<RawSqlWriteTracking, "processfocus/RawSqlWriteTracking", (client: SqlClient, tables: readonly string[]) => Effect.Effect<void>>;
17
+ /** Runtime adapter for explicitly marked raw writes. */
18
+ export declare class RawSqlWriteTracking extends RawSqlWriteTracking_base {
19
+ }
20
+ /**
21
+ * Run one raw write using the supplied runtime SQL client and mark its table
22
+ * for watched List refresh. Mark inside `SqlClient.withTransaction` to defer
23
+ * refresh until the outer commit. Handle statement errors outside this call.
24
+ *
25
+ * @example
26
+ * yield* markRawSqlWrite(orders, (sql) =>
27
+ * sql`UPDATE orders SET status = ${status} WHERE id = ${id}`,
28
+ * )
29
+ */
30
+ export declare function markRawSqlWrite<A, E, R>(table: WatchedTable, write: (client: SqlClient) => Effect.Effect<A, E, R>): Effect.Effect<A, E, R | SqlClient>;
9
31
  declare const ListItemQueryNotDefinedError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
10
32
  readonly _tag: "ListItemQueryNotDefinedError";
11
33
  } & Readonly<A>;
@@ -193,6 +215,8 @@ export interface ListProps<TOutput extends Schema.Struct.Fields, R = never, TFor
193
215
  readonly defaultPageSize?: number;
194
216
  /** Query function returning paginated results */
195
217
  readonly query: ListQueryFunction<TOutput, R>;
218
+ /** Refresh after managed Drizzle writes or writes marked with {@link markRawSqlWrite}. */
219
+ readonly watchTables?: readonly [WatchedTable, ...WatchedTable[]];
196
220
  /** Optional export schema overriding the normal list output for CSV exports */
197
221
  readonly exportOutput?: TExportOutput;
198
222
  /** Optional export query overriding the normal list query for CSV exports */
@@ -258,6 +282,7 @@ export declare const MAX_PAGE_SIZE = 100;
258
282
  */
259
283
  export declare class List<TOutput extends Schema.Struct.Fields = Schema.Struct.Fields, R = never, TId extends string = string, TForm extends Schema.Struct.Fields = Schema.Struct.Fields, TExportOutput extends Schema.Struct.Fields | undefined = undefined, TCreate extends Schema.Struct.Fields = Schema.Struct.Fields> extends Construct {
260
284
  readonly isList = true;
285
+ readonly watchTableNames: readonly string[];
261
286
  private readonly _create?;
262
287
  readonly browser: ListProps<TOutput, R, TForm, TExportOutput, TCreate>["browser"];
263
288
  readonly createBrowser: NonNullable<ListProps<TOutput, R, TForm, TExportOutput, TCreate>["create"]>["browser"];
@@ -1,6 +1,4 @@
1
- import type { DocumentStoreService, EmailSender, NotificationDeliveryConfig } from "@processfocus/runtime";
2
- import type { Layer } from "effect";
3
- import type { HttpClient } from "effect/http";
1
+ import type { NotificationEmailLayer } from "@processfocus/runtime";
4
2
  import type { BusinessCalendarConfig } from "../../../business-calendar/src/index.js";
5
3
  import type { DocumentStore } from "./document-store.js";
6
4
  import type { Form } from "./form.js";
@@ -20,7 +18,6 @@ export declare const validateTimeZone: (timeZone: string) => void;
20
18
  * The real organisation lives in the organisation package, and has
21
19
  * various helper methods to use it.
22
20
  */
23
- type NotificationEmailLayer = Layer.Layer<EmailSender | NotificationDeliveryConfig, unknown, DocumentStoreService | HttpClient.HttpClient>;
24
21
  export interface OrganisationProps {
25
22
  /** Platform branch or exact commit selected for a hosted deploy. */
26
23
  readonly platformRef?: string | undefined;
@@ -53,7 +50,7 @@ export interface OrganisationProps {
53
50
  * Default when no calendar is specified: a 24/7 calendar.
54
51
  */
55
52
  readonly businessCalendar?: BusinessCalendarConfig | undefined;
56
- /** The same notification layer used by the job worker, independent of other job services. */
53
+ /** @deprecated Export a plain `NotificationEmailLayer` from the project module instead. */
57
54
  readonly notificationEmailLayer?: (() => NotificationEmailLayer) | undefined;
58
55
  }
59
56
  /**
@@ -91,6 +88,7 @@ export declare class Organisation extends OrgUnitClass {
91
88
  * Defines working hours, holidays, and special periods.
92
89
  */
93
90
  readonly businessCalendar?: BusinessCalendarConfig | undefined;
91
+ /** @deprecated Export a plain `NotificationEmailLayer` from the project module instead. */
94
92
  readonly notificationEmailLayer: OrganisationProps["notificationEmailLayer"];
95
93
  constructor(props: OrganisationProps);
96
94
  /**
@@ -177,4 +175,3 @@ export declare class Organisation extends OrgUnitClass {
177
175
  orphanElse: string[];
178
176
  }>;
179
177
  }
180
- export {};
@@ -7,7 +7,7 @@ export type { CamelCase, FlowContext, ForEachOutput, FormStepMeta, MergeFormStep
7
7
  export { type ConditionOptions, ElseBranch, type ElseTransitionOptions, FlowPath, type MergeState, type OnErrorOptions, type ScheduleOptions, type TransitionOptions, } from "./process/src/lib/flow-path.js";
8
8
  export { Form, type FormEmbedConfig, type FormPublicCompletionConfig, type FormStepProps, LookupFieldNotFoundError, type PublicCompletionCorrectionConfig, type PublicCompletionEmailTemplate, type PublicCompletionRecipient, type Summary, } from "./process/src/lib/form.js";
9
9
  export { Invitation, type InvitationProps, } from "./process/src/lib/invitation.js";
10
- export { DEFAULT_PAGE_SIZE, List, type ListDeleteFunction, type ListItemQueryContext, type ListItemQueryFunction, type ListProps, type ListQueryContext, type ListQueryFunction, type ListQueryResult, type ListSortDirection, type ListSortInput, ListSortable, type ListUpdateFunction, ListUpdateValidationError, ListVisibleInList, MAX_PAGE_SIZE, type OutputItem, } from "./process/src/lib/list.js";
10
+ export { DEFAULT_PAGE_SIZE, List, type ListDeleteFunction, type ListItemQueryContext, type ListItemQueryFunction, type ListProps, type ListQueryContext, type ListQueryFunction, type ListQueryResult, type ListSortDirection, type ListSortInput, ListSortable, type ListUpdateFunction, ListUpdateValidationError, ListVisibleInList, MAX_PAGE_SIZE, type OutputItem, markRawSqlWrite, } from "./process/src/lib/list.js";
11
11
  export { type DependentQueryInput, LookupAccessor, LookupBuilder, type QueryInput, } from "./process/src/lib/lookup-accessor.js";
12
12
  export { NodeStep, type NodeStepProps, } from "./process/src/lib/node_step.js";
13
13
  export { OrgUnit, type OrgUnitProps, type OrgUnitType, } from "./process/src/lib/org-unit.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "processfocus",
3
- "version": "0.1.0-next.4",
3
+ "version": "0.1.0-next.5",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "repository": {
@@ -45,7 +45,7 @@
45
45
  "./package.json": "./package.json"
46
46
  },
47
47
  "dependencies": {
48
- "@processfocus/runtime": "0.1.0-next.4",
48
+ "@processfocus/runtime": "0.1.0-next.5",
49
49
  "constructs": "^10.8.1",
50
50
  "effect": "4.1.4",
51
51
  "graphology": "^0.26.0",