@query-farm/vgi 0.48.2 → 0.48.3

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 (43) hide show
  1. package/README.md +27 -0
  2. package/dist/arrow/impl-arrowjs/iterate.d.ts +7 -3
  3. package/dist/arrow/impl-flechette/iterate.d.ts +2 -1
  4. package/dist/client-entry.js +9 -25
  5. package/dist/client-entry.js.map +3 -3
  6. package/dist/functions/aggregate.d.ts +2 -1
  7. package/dist/functions/copy-from.d.ts +2 -1
  8. package/dist/functions/copy-to.d.ts +2 -1
  9. package/dist/functions/scalar.d.ts +2 -1
  10. package/dist/functions/table-buffering.d.ts +2 -1
  11. package/dist/functions/table-in-out.d.ts +3 -2
  12. package/dist/functions/table.d.ts +2 -1
  13. package/dist/functions/types.d.ts +2 -1
  14. package/dist/index.core.d.ts +2 -1
  15. package/dist/index.js +131 -39
  16. package/dist/index.js.map +18 -17
  17. package/dist/metadata/types.d.ts +3 -1
  18. package/dist/secrets/helpers.d.ts +31 -3
  19. package/dist/secrets/requirements.d.ts +38 -0
  20. package/dist/serve-entry.js +9 -25
  21. package/dist/serve-entry.js.map +5 -5
  22. package/dist/worker-cf-entry.d.ts +2 -2
  23. package/dist/worker-cf-entry.js +161 -32
  24. package/dist/worker-cf-entry.js.map +15 -13
  25. package/package.json +1 -1
  26. package/src/arrow/impl-arrowjs/iterate.ts +17 -40
  27. package/src/arrow/impl-flechette/iterate.ts +5 -24
  28. package/src/catalog/read-only.ts +6 -3
  29. package/src/functions/aggregate.ts +3 -2
  30. package/src/functions/copy-from.ts +3 -2
  31. package/src/functions/copy-to.ts +2 -1
  32. package/src/functions/scalar.ts +3 -2
  33. package/src/functions/table-buffering.ts +3 -2
  34. package/src/functions/table-in-out.ts +5 -4
  35. package/src/functions/table.ts +3 -2
  36. package/src/functions/types.ts +2 -1
  37. package/src/index.core.ts +10 -0
  38. package/src/metadata/resolve.ts +2 -1
  39. package/src/metadata/serialize.ts +25 -5
  40. package/src/metadata/types.ts +3 -1
  41. package/src/secrets/helpers.ts +96 -9
  42. package/src/secrets/requirements.ts +121 -0
  43. package/src/worker-cf-entry.ts +14 -0
@@ -1,3 +1,4 @@
1
+ import type { SecretRequirement } from "../secrets/requirements.js";
1
2
  import { FunctionStability, NullHandling, ArgumentMonotonicity, OrderPreservation, OrderDependence, DistinctDependence } from "../types.js";
2
3
  export declare enum CatalogFunctionType {
3
4
  SCALAR = "SCALAR",
@@ -45,7 +46,8 @@ export interface ResolvedMetadata {
45
46
  nullHandling: NullHandling;
46
47
  argumentMonotonicity: ArgumentMonotonicity[] | null;
47
48
  requiredSettings: string[];
48
- requiredSecrets: string[];
49
+ /** Validated static secret requirements (FunctionInfo `required_secrets`). */
50
+ requiredSecrets: SecretRequirement[];
49
51
  projectionPushdown: boolean;
50
52
  filterPushdown: boolean;
51
53
  samplingPushdown: boolean;
@@ -2,14 +2,42 @@ export type SecretFields = Record<string, any>;
2
2
  export type SecretsDict = Record<string, SecretFields>;
3
3
  /** The DuckDB secret type of the named secret (its serialized `type` field). */
4
4
  export declare function secretType(secrets: SecretsDict, name: string): string | undefined;
5
- /** Every resolved secret whose serialized `type` field matches `type`. */
5
+ /**
6
+ * Every resolved secret whose serialized `type` field matches `type`, in
7
+ * delivery order. Falls back to an untyped secret keyed by `type` only when no
8
+ * secret carries the type.
9
+ */
6
10
  export declare function secretsOfType(secrets: SecretsDict, type: string): SecretFields[];
11
+ /**
12
+ * The secret a by-TYPE request refers to: a secret of `type` with an empty
13
+ * scope, else the first secret of `type`, else undefined. This is the rule the
14
+ * client applies to a `requiredSecrets: ["<type>"]` declaration, so it picks the
15
+ * secret that declaration resolved even when other same-type secrets (from
16
+ * scoped declarations) were delivered alongside it.
17
+ */
18
+ export declare function secretOfType(secrets: SecretsDict, type: string): SecretFields | undefined;
19
+ /**
20
+ * Like {@link secretOfType}, but throws when no secret of `type` was resolved.
21
+ * Call it from `onBind` to fail the bind of a function that cannot run without
22
+ * credentials. The message names the type and never includes a secret value.
23
+ */
24
+ export declare function requireSecretOfType(secrets: SecretsDict, type: string): SecretFields;
25
+ /**
26
+ * The secret with DuckDB name `name` (its key in the resolved batch). With
27
+ * `type`, only if that secret's `type` field is `type` (or absent, for a bare
28
+ * key/value struct) — the rule the client applies to a by-name request.
29
+ */
30
+ export declare function secretByName(secrets: SecretsDict, name: string, type?: string): SecretFields | undefined;
7
31
  /**
8
32
  * The secret whose `scope` is the longest prefix of `path`. The connector
9
33
  * serializes each secret's scope as a newline-joined list of prefixes; a secret
10
34
  * with no (or empty) scope matches as a last-resort fallback. Returns undefined
11
- * only when there are no candidate secrets.
35
+ * when no scope is a prefix of `path` and no unscoped secret was delivered.
12
36
  */
13
37
  export declare function secretForScope(secrets: SecretsDict, path: string): SecretFields | undefined;
14
- /** Like {@link secretForScope} but only over secrets of `type`. */
38
+ /**
39
+ * Like {@link secretForScope} but only over secrets of `type`: the one whose
40
+ * scope is the longest prefix of `path`, else one of `type` with an empty scope,
41
+ * else undefined.
42
+ */
15
43
  export declare function secretForScopeOfType(secrets: SecretsDict, path: string, type: string): SecretFields | undefined;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * A secret requirement in object form. `scope` asks the client for the secret of
3
+ * `secretType` whose scope is the longest prefix of it; `secretName` asks for one
4
+ * secret by its DuckDB name (and takes precedence over `scope`, as it does on
5
+ * the client). Neither means "a secret of this type with an empty scope".
6
+ *
7
+ * The snake_case spelling of the wire entry (`secret_type` / `secret_name`) is
8
+ * accepted too.
9
+ */
10
+ export interface SecretRequirementSpec {
11
+ secretType?: string;
12
+ scope?: string | null;
13
+ secretName?: string | null;
14
+ secret_type?: string;
15
+ secret_name?: string | null;
16
+ }
17
+ /**
18
+ * One `requiredSecrets` entry: a bare secret type (the simplest form — "a secret
19
+ * of this type"), or a {@link SecretRequirementSpec} with a scope or a name.
20
+ */
21
+ export type RequiredSecret = string | SecretRequirementSpec;
22
+ /** A validated, normalized requirement — the shape sent on the wire. */
23
+ export interface SecretRequirement {
24
+ secretType: string;
25
+ scope: string | null;
26
+ secretName: string | null;
27
+ }
28
+ /**
29
+ * Validate and normalize a `requiredSecrets` declaration. Throws on anything
30
+ * that is not a list of bare type strings / requirement objects, on an empty
31
+ * type, on unknown object keys (a typo such as `{ type: "s3" }` would otherwise
32
+ * declare nothing), and on conflicting camelCase/snake_case spellings.
33
+ * Duplicate requirements (same type, scope and name) are collapsed.
34
+ *
35
+ * @param value The declared `requiredSecrets` (undefined → no requirements).
36
+ * @param functionName Used in error messages.
37
+ */
38
+ export declare function normalizeRequiredSecrets(value: unknown, functionName?: string): SecretRequirement[];
@@ -2133,30 +2133,14 @@ function batchToSecretDict(batch) {
2133
2133
  const result = {};
2134
2134
  for (const field of a.schema.fields) {
2135
2135
  const col = a.getChild(field.name);
2136
- if (col) {
2137
- const type = field.type;
2138
- const val = codecFor(type).canonicalToRich(readCanonicalValue(type, col, 0));
2139
- let key = field.name;
2140
- let scope;
2141
- if (field.name.startsWith("secret_")) {
2142
- const secretType = field.metadata?.get?.("secret_type");
2143
- if (secretType) {
2144
- key = secretType;
2145
- scope = field.metadata?.get?.("scope") ?? undefined;
2146
- }
2147
- }
2148
- if (val && typeof val === "object" && !ArrayBuffer.isView(val)) {
2149
- const dict = { ...val };
2150
- if (key in result) {
2151
- throw new Error(`batchToSecretDict: duplicate secret_type '${key}' (scope=${scope ?? "none"}). ` + `Use scoped secrets with distinct scopes to avoid collisions.`);
2152
- }
2153
- result[key] = dict;
2154
- if (scope) {
2155
- result[`${key}:${scope}`] = dict;
2156
- }
2157
- } else if (val === null || val === undefined) {} else {
2158
- result[key] = {};
2159
- }
2136
+ if (!col)
2137
+ continue;
2138
+ const type = field.type;
2139
+ const val = codecFor(type).canonicalToRich(readCanonicalValue(type, col, 0));
2140
+ if (val && typeof val === "object" && !ArrayBuffer.isView(val)) {
2141
+ result[field.name] = { ...val };
2142
+ } else if (val !== null && val !== undefined) {
2143
+ result[field.name] = {};
2160
2144
  }
2161
2145
  }
2162
2146
  return result;
@@ -11925,4 +11909,4 @@ export {
11925
11909
  serveVgiWorker
11926
11910
  };
11927
11911
 
11928
- //# debugId=AA979855B0C12EAC64756E2164756E21
11912
+ //# debugId=0D0A3CC5D765A2FD64756E2164756E21