@xano/cli 1.0.4 → 1.0.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.
Files changed (65) hide show
  1. package/README.md +107 -4
  2. package/dist/base-command.d.ts +27 -0
  3. package/dist/base-command.js +124 -1
  4. package/dist/commands/auth/index.d.ts +45 -1
  5. package/dist/commands/auth/index.js +197 -29
  6. package/dist/commands/function/run/index.d.ts +40 -0
  7. package/dist/commands/function/run/index.js +244 -0
  8. package/dist/commands/knowledge/{pull → get}/index.d.ts +6 -2
  9. package/dist/commands/knowledge/get/index.js +126 -0
  10. package/dist/commands/knowledge/{push → list}/index.d.ts +6 -8
  11. package/dist/commands/knowledge/list/index.js +135 -0
  12. package/dist/commands/sandbox/pull/index.js +12 -2
  13. package/dist/commands/sandbox/push/index.d.ts +1 -1
  14. package/dist/commands/sandbox/push/index.js +19 -14
  15. package/dist/commands/sandbox/reset/index.js +12 -0
  16. package/dist/commands/static_host/build/create/index.d.ts +9 -1
  17. package/dist/commands/static_host/build/create/index.js +54 -4
  18. package/dist/commands/static_host/build/delete/index.d.ts +19 -0
  19. package/dist/commands/static_host/build/delete/index.js +114 -0
  20. package/dist/commands/static_host/build/get/index.d.ts +1 -1
  21. package/dist/commands/static_host/build/get/index.js +16 -10
  22. package/dist/commands/static_host/build/pull/index.d.ts +52 -0
  23. package/dist/commands/static_host/build/pull/index.js +300 -0
  24. package/dist/commands/static_host/build/push/index.d.ts +23 -0
  25. package/dist/commands/static_host/build/push/index.js +228 -0
  26. package/dist/commands/static_host/create/index.d.ts +17 -0
  27. package/dist/commands/static_host/create/index.js +86 -0
  28. package/dist/commands/static_host/deploy/index.d.ts +18 -0
  29. package/dist/commands/static_host/deploy/index.js +105 -0
  30. package/dist/commands/static_host/edit/index.d.ts +23 -0
  31. package/dist/commands/static_host/edit/index.js +151 -0
  32. package/dist/commands/static_host/get/index.d.ts +18 -0
  33. package/dist/commands/static_host/get/index.js +94 -0
  34. package/dist/commands/static_host/migrate/index.d.ts +44 -0
  35. package/dist/commands/static_host/migrate/index.js +205 -0
  36. package/dist/commands/tenant/snapshot/create/index.d.ts +17 -0
  37. package/dist/commands/tenant/snapshot/create/index.js +78 -0
  38. package/dist/commands/tenant/snapshot/delete/index.d.ts +19 -0
  39. package/dist/commands/tenant/snapshot/delete/index.js +102 -0
  40. package/dist/commands/tenant/snapshot/list/index.d.ts +16 -0
  41. package/dist/commands/tenant/snapshot/list/index.js +96 -0
  42. package/dist/commands/tenant/snapshot/swap/index.d.ts +19 -0
  43. package/dist/commands/tenant/snapshot/swap/index.js +103 -0
  44. package/dist/commands/tenant/unit_test/run/index.d.ts +1 -0
  45. package/dist/commands/tenant/unit_test/run/index.js +7 -0
  46. package/dist/commands/tenant/unit_test/run_all/index.js +7 -3
  47. package/dist/commands/unit_test/run/index.d.ts +1 -0
  48. package/dist/commands/unit_test/run/index.js +8 -0
  49. package/dist/commands/unit_test/run_all/index.js +7 -3
  50. package/dist/commands/workspace/pull/index.js +13 -2
  51. package/dist/commands/workspace/push/index.d.ts +1 -1
  52. package/dist/commands/workspace/push/index.js +15 -5
  53. package/dist/utils/function-input.d.ts +77 -0
  54. package/dist/utils/function-input.js +148 -0
  55. package/dist/utils/knowledge-sync.d.ts +84 -79
  56. package/dist/utils/knowledge-sync.js +376 -323
  57. package/dist/utils/multidoc-push.d.ts +30 -18
  58. package/dist/utils/multidoc-push.js +284 -148
  59. package/dist/utils/reference-checker.js +2 -2
  60. package/dist/utils/static-host-files.d.ts +21 -0
  61. package/dist/utils/static-host-files.js +41 -0
  62. package/oclif.manifest.json +4574 -3045
  63. package/package.json +7 -1
  64. package/dist/commands/knowledge/pull/index.js +0 -86
  65. package/dist/commands/knowledge/push/index.js +0 -126
@@ -1,108 +1,113 @@
1
- import { Command } from '@oclif/core';
2
- /** A knowledge record as returned by the Metadata API list endpoint. */
3
- export interface KnowledgeItem {
4
- branch?: {
5
- id: number;
6
- };
7
- content?: string;
1
+ export declare const KNOWLEDGE_DIR = "knowledge";
2
+ export type KnowledgeType = 'agents.md' | 'doc' | 'skill';
3
+ /** A reference file attached to a skill (knowledge_file). */
4
+ export interface KnowledgeFile {
5
+ content: string;
6
+ /** Path relative to the skill's `references/` folder, POSIX-separated. */
7
+ name: string;
8
+ }
9
+ /** A workspace-scoped knowledge object as exchanged with the API. */
10
+ export interface KnowledgeObject {
11
+ content: string;
8
12
  description?: string;
9
13
  enabled?: boolean;
10
- id: number;
11
- knowledge_type?: string;
14
+ files?: KnowledgeFile[];
15
+ guid?: string;
16
+ knowledge_type: KnowledgeType;
12
17
  mode?: string;
13
18
  name: string;
14
- references?: string[];
15
19
  scope?: string;
16
- tag?: string[];
17
20
  }
18
- /** A local knowledge file: its API name (relative path) and content. */
19
- export interface LocalKnowledgeEntry {
20
- content: string;
21
+ /** A locally-collected object that also remembers its primary file on disk (for GUID writeback). */
22
+ export interface LocalKnowledgeObject extends KnowledgeObject {
21
23
  filePath: string;
22
- name: string;
23
24
  }
24
- export interface KnowledgePlan {
25
- creates: LocalKnowledgeEntry[];
26
- deletes: KnowledgeItem[];
27
- unchanged: Array<{
28
- entry: LocalKnowledgeEntry;
29
- remote: KnowledgeItem;
30
- }>;
31
- updates: Array<{
32
- entry: LocalKnowledgeEntry;
33
- remote: KnowledgeItem;
25
+ export interface KnowledgePushBody {
26
+ branch?: string;
27
+ delete?: boolean;
28
+ dry_run?: boolean;
29
+ force?: boolean;
30
+ items: KnowledgeObject[];
31
+ }
32
+ export interface KnowledgePushResult {
33
+ deleted?: number;
34
+ guid_map?: Array<{
35
+ guid: string;
36
+ name: string;
34
37
  }>;
38
+ imported?: number;
39
+ operations?: KnowledgeDryRunOperation[];
40
+ summary?: Record<string, KnowledgeDryRunSummary>;
35
41
  }
36
- export interface KnowledgePushFlags {
37
- delete: boolean;
38
- 'dry-run': boolean;
39
- exclude?: string[];
40
- force: boolean;
41
- include?: string[];
42
- sync: boolean;
43
- verbose: boolean;
42
+ export interface KnowledgeDryRunOperation {
43
+ action: string;
44
+ name: string;
45
+ type: string;
44
46
  }
45
- export interface KnowledgeApiContext {
46
- accessToken: string;
47
- /** Branch name ('' = live branch) */
48
- branch: string;
49
- instanceOrigin: string;
50
- verboseFetch: (url: string, options: RequestInit, verbose: boolean, authToken?: string) => Promise<Response>;
51
- workspaceId: string;
47
+ export interface KnowledgeDryRunSummary {
48
+ created: number;
49
+ deleted: number;
50
+ unchanged: number;
51
+ updated: number;
52
52
  }
53
- export interface KnowledgePushContext extends KnowledgeApiContext {
54
- cliVersion: string;
55
- command: Command;
56
- inputDir: string;
53
+ export interface KnowledgeDryRunResult {
54
+ operations: KnowledgeDryRunOperation[];
55
+ summary: Record<string, KnowledgeDryRunSummary>;
57
56
  }
58
- export declare const MAX_NAME_LENGTH = 200;
57
+ type VerboseFetch = (url: string, options: RequestInit, verbose: boolean, authToken?: string) => Promise<Response>;
59
58
  /**
60
- * Validate a knowledge name (a relative path like "some/thing/CLAUDE.md")
61
- * against the Metadata API's accepted character set and length.
62
- * Returns null when valid, otherwise a human-readable reason.
59
+ * Build a primary `.md` file body: YAML frontmatter (built from the object's
60
+ * structured fields) followed by the markdown content.
63
61
  */
64
- export declare function validateKnowledgeName(name: string): null | string;
62
+ export declare function buildPrimaryContent(obj: KnowledgeObject): string;
65
63
  /**
66
- * Resolve a knowledge name to a local file path inside baseDir, rejecting
67
- * names that would escape it (absolute paths, "..", etc.).
68
- * Returns null when the name is unsafe.
64
+ * Split a primary `.md` file into its frontmatter fields and markdown body.
65
+ * Returns `{meta: {}, body: <raw>}` when there is no leading `---` block.
69
66
  */
70
- export declare function safeKnowledgePath(baseDir: string, name: null | string | undefined): null | string;
67
+ export declare function parsePrimaryContent(raw: string): {
68
+ body: string;
69
+ meta: Record<string, unknown>;
70
+ };
71
+ /** Read just `guid`/`name` from frontmatter (used by GUID matching). */
72
+ export declare function parseFrontmatter(content: string): {
73
+ guid?: string;
74
+ name?: string;
75
+ };
71
76
  /**
72
- * Infer the knowledge_type for a newly created knowledge item from its
73
- * filename. AGENTS.md and SKILL.md are special-cased; everything else is a doc.
77
+ * Write knowledge objects under `<outputDir>/knowledge/`, building frontmatter
78
+ * and laying out skill reference files under `<skill>/references/`.
79
+ * Returns the number of files written (primaries + references).
74
80
  */
75
- export declare function inferKnowledgeType(name: string): string;
81
+ export declare function writeKnowledge(objects: KnowledgeObject[], outputDir: string): number;
76
82
  /**
77
- * Recursively collect all files under a directory, skipping hidden files,
78
- * hidden directories, and node_modules. Sorted for deterministic ordering.
83
+ * Walk `<inputDir>/knowledge/`, reconstructing structured knowledge objects from
84
+ * primary `.md` files (frontmatter → fields, body → content) and attaching each
85
+ * skill's `references/` files. Include/exclude globs are matched against
86
+ * `knowledge/<path>` (relative to inputDir), consistent with multidoc filtering.
87
+ * Returns `[]` when the directory is absent.
79
88
  */
80
- export declare function collectKnowledgeFiles(dir: string): string[];
89
+ export declare function collectKnowledgeObjects(inputDir: string, include?: string[], exclude?: string[]): LocalKnowledgeObject[];
90
+ /** Strip the local-only `filePath` before sending objects to the API. */
91
+ export declare function toPushItems(objects: LocalKnowledgeObject[]): KnowledgeObject[];
81
92
  /**
82
- * Read local files into knowledge entries. The knowledge name is the path
83
- * relative to inputDir, using forward slashes.
93
+ * GET workspace knowledge objects (with content). Returns `[]` on 404 (instance
94
+ * without the feature) or any network error, so pull degrades gracefully.
84
95
  */
85
- export declare function readKnowledgeEntries(files: string[], inputDir: string): LocalKnowledgeEntry[];
96
+ export declare function fetchKnowledge(baseUrl: string, branch: string, accessToken: string, verboseFetch: VerboseFetch, verbose: boolean): Promise<KnowledgeObject[]>;
86
97
  /**
87
- * Compute the create/update/delete plan by matching local entries against
88
- * remote knowledge items by name.
98
+ * POST knowledge objects to the workspace. Throws on non-2xx. When `body.dry_run`
99
+ * is set the result may carry `operations`/`summary` instead of `imported`.
89
100
  */
90
- export declare function buildKnowledgePlan(localEntries: LocalKnowledgeEntry[], remoteItems: KnowledgeItem[]): KnowledgePlan;
91
- export declare function renderKnowledgePreview(plan: KnowledgePlan, opts: {
92
- cliVersion: string;
93
- instanceOrigin: string;
94
- label: string;
95
- partial: boolean;
96
- willDelete: boolean;
97
- }, log: (msg: string) => void): void;
101
+ export declare function pushKnowledge(url: string, accessToken: string, verboseFetch: VerboseFetch, verbose: boolean, body: KnowledgePushBody): Promise<KnowledgePushResult>;
98
102
  /**
99
- * Fetch all knowledge items (with content) for a workspace/branch.
103
+ * Compute a dry-run-style preview by diffing local objects against server
104
+ * objects (match by `guid`, then `name`). Used when the server doesn't honor
105
+ * the `dry_run` flag.
100
106
  */
101
- export declare function fetchKnowledgeList(ctx: KnowledgeApiContext, verbose: boolean): Promise<KnowledgeItem[]>;
107
+ export declare function knowledgePreview(local: KnowledgeObject[], server: KnowledgeObject[], willDelete: boolean): KnowledgeDryRunResult;
102
108
  /**
103
- * Execute a knowledge push: collect local files, diff against remote by name,
104
- * preview, confirm, then apply creates/updates/deletes through the Metadata API.
105
- * Mirrors the UX of `workspace push` (partial by default, --sync for full,
106
- * --delete to remove remote-only items, --dry-run / --force).
109
+ * Set or update `guid:` in a primary `.md` file's YAML frontmatter.
110
+ * Returns true if the file was modified.
107
111
  */
108
- export declare function executeKnowledgePush(ctx: KnowledgePushContext, flags: KnowledgePushFlags): Promise<void>;
112
+ export declare function syncGuidToFrontmatter(filePath: string, guid: string): boolean;
113
+ export {};