kalup 0.1.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 (145) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +4 -0
  3. package/README.md +68 -0
  4. package/bin/kalup.mjs +13 -0
  5. package/dist/commands-C--Xsk1p.mjs +16145 -0
  6. package/dist/commands.d.mts +191 -0
  7. package/dist/commands.mjs +2 -0
  8. package/dist/context-D10Syqfd.d.mts +1265 -0
  9. package/dist/host-BJWvo3sX.mjs +390 -0
  10. package/dist/host.d.mts +44 -0
  11. package/dist/host.mjs +2 -0
  12. package/dist/index.d.mts +1 -0
  13. package/dist/index.mjs +14 -0
  14. package/dist/schemas/blueprint-1.schema.json +151 -0
  15. package/dist/schemas/blueprints-lock-1.schema.json +76 -0
  16. package/dist/schemas/ir-1.schema.json +379 -0
  17. package/dist/schemas/plan-1.schema.json +868 -0
  18. package/dist/schemas/state-1.schema.json +98 -0
  19. package/docs/apply.md +64 -0
  20. package/docs/blueprints.md +86 -0
  21. package/docs/compare.md +73 -0
  22. package/docs/config.md +88 -0
  23. package/docs/dictionary.md +43 -0
  24. package/docs/errors/E_ACCEPT_UNMATCHED.md +17 -0
  25. package/docs/errors/E_APPROVAL_REQUIRED.md +17 -0
  26. package/docs/errors/E_APPROVE_CREDENTIAL.md +17 -0
  27. package/docs/errors/E_APPROVE_MISMATCH.md +17 -0
  28. package/docs/errors/E_AUTH.md +17 -0
  29. package/docs/errors/E_BAD_CHAIN.md +21 -0
  30. package/docs/errors/E_BINDING_CHANGED.md +17 -0
  31. package/docs/errors/E_BIOME_CONFIG.md +17 -0
  32. package/docs/errors/E_BLUEPRINT_ADDED.md +17 -0
  33. package/docs/errors/E_BLUEPRINT_COLLISION.md +17 -0
  34. package/docs/errors/E_BLUEPRINT_INTEGRITY.md +17 -0
  35. package/docs/errors/E_BLUEPRINT_LOCK.md +17 -0
  36. package/docs/errors/E_BLUEPRINT_ORIGINAL.md +17 -0
  37. package/docs/errors/E_BLUEPRINT_REF.md +17 -0
  38. package/docs/errors/E_BLUEPRINT_REQUIRES.md +17 -0
  39. package/docs/errors/E_BLUEPRINT_SCHEMA.md +17 -0
  40. package/docs/errors/E_BLUEPRINT_SOURCE.md +17 -0
  41. package/docs/errors/E_BLUEPRINT_UNKNOWN.md +17 -0
  42. package/docs/errors/E_BUDGET.md +17 -0
  43. package/docs/errors/E_CANCELLED.md +21 -0
  44. package/docs/errors/E_CONFIG_EXISTS.md +17 -0
  45. package/docs/errors/E_DAILY_LIMIT.md +17 -0
  46. package/docs/errors/E_DEFAULT_TARGET.md +17 -0
  47. package/docs/errors/E_DUPLICATE_ADDRESS.md +17 -0
  48. package/docs/errors/E_DUPLICATE_ALIAS.md +24 -0
  49. package/docs/errors/E_DUPLICATE_KEY.md +24 -0
  50. package/docs/errors/E_DUPLICATE_OPTION.md +25 -0
  51. package/docs/errors/E_DUPLICATE_PORTAL.md +24 -0
  52. package/docs/errors/E_FIRST_PULL.md +18 -0
  53. package/docs/errors/E_HS_PREFIX.md +21 -0
  54. package/docs/errors/E_HTTP.md +17 -0
  55. package/docs/errors/E_INCOMPLETE.md +23 -0
  56. package/docs/errors/E_IR_SCHEMA.md +18 -0
  57. package/docs/errors/E_JOURNAL_WRITE.md +17 -0
  58. package/docs/errors/E_KEY_COLLISION.md +22 -0
  59. package/docs/errors/E_KEY_INVALID.md +19 -0
  60. package/docs/errors/E_LIFECYCLE.md +23 -0
  61. package/docs/errors/E_LOCKED.md +17 -0
  62. package/docs/errors/E_LOCK_DIR.md +17 -0
  63. package/docs/errors/E_MISSING_EXPORT.md +17 -0
  64. package/docs/errors/E_MISSING_KEY.md +17 -0
  65. package/docs/errors/E_NOT_DATA.md +21 -0
  66. package/docs/errors/E_NO_CONFIG.md +17 -0
  67. package/docs/errors/E_NO_TARGETS.md +17 -0
  68. package/docs/errors/E_OVERRIDE_AMBIGUOUS.md +21 -0
  69. package/docs/errors/E_OVERRIDE_DEFINITION.md +26 -0
  70. package/docs/errors/E_OVERRIDE_NAME.md +23 -0
  71. package/docs/errors/E_PLAN_DELETE.md +17 -0
  72. package/docs/errors/E_PLAN_DESTINATION.md +17 -0
  73. package/docs/errors/E_PLAN_DIGEST.md +17 -0
  74. package/docs/errors/E_PLAN_INVALID.md +17 -0
  75. package/docs/errors/E_PLAN_RISK.md +17 -0
  76. package/docs/errors/E_PLAN_SCHEMA.md +17 -0
  77. package/docs/errors/E_PLAN_STALE.md +17 -0
  78. package/docs/errors/E_PLAN_VERSION.md +18 -0
  79. package/docs/errors/E_POLICY_CHANGED.md +17 -0
  80. package/docs/errors/E_PORTAL_ID.md +17 -0
  81. package/docs/errors/E_PREVENT_DESTROY.md +17 -0
  82. package/docs/errors/E_PROJECT_WRITE.md +17 -0
  83. package/docs/errors/E_PROTECTED_SAVED_PLAN.md +17 -0
  84. package/docs/errors/E_PULL_INVALID.md +20 -0
  85. package/docs/errors/E_RATE_LIMIT.md +17 -0
  86. package/docs/errors/E_REBIND_STANDARD.md +17 -0
  87. package/docs/errors/E_REFERENCE_DEFINITION.md +21 -0
  88. package/docs/errors/E_RM_DEPENDENTS.md +17 -0
  89. package/docs/errors/E_SCOPE.md +17 -0
  90. package/docs/errors/E_SETTING_LEVEL.md +21 -0
  91. package/docs/errors/E_SETTING_VALUE.md +23 -0
  92. package/docs/errors/E_SNAPSHOT.md +17 -0
  93. package/docs/errors/E_STANDARD_OBJECT.md +21 -0
  94. package/docs/errors/E_STATE_CHANGED.md +19 -0
  95. package/docs/errors/E_STATE_CONFLICT.md +17 -0
  96. package/docs/errors/E_STATE_INVALID.md +17 -0
  97. package/docs/errors/E_STATE_SCHEMA.md +17 -0
  98. package/docs/errors/E_STATE_WRITE.md +19 -0
  99. package/docs/errors/E_STRICT_WITHOUT_OPTIONS.md +21 -0
  100. package/docs/errors/E_TAKE_UNMATCHED.md +19 -0
  101. package/docs/errors/E_TARGET_NAME.md +17 -0
  102. package/docs/errors/E_TARGET_PORTAL_MISMATCH.md +19 -0
  103. package/docs/errors/E_TARGET_REQUIRED.md +17 -0
  104. package/docs/errors/E_TOMBSTONE_ADDRESS.md +23 -0
  105. package/docs/errors/E_TOMBSTONE_CONFLICT.md +17 -0
  106. package/docs/errors/E_TYPE_FIELDTYPE.md +21 -0
  107. package/docs/errors/E_UNCERTAIN_WRITE.md +17 -0
  108. package/docs/errors/E_UNEXPECTED.md +17 -0
  109. package/docs/errors/E_UNKNOWN_BUILDER.md +21 -0
  110. package/docs/errors/E_UNKNOWN_GROUP.md +21 -0
  111. package/docs/errors/E_UNKNOWN_INCLUDE.md +17 -0
  112. package/docs/errors/E_UNKNOWN_OBJECT.md +17 -0
  113. package/docs/errors/E_UNKNOWN_OVERRIDE.md +17 -0
  114. package/docs/errors/E_UNKNOWN_TARGET.md +17 -0
  115. package/docs/errors/E_UNREACHABLE.md +17 -0
  116. package/docs/errors/E_UNSUPPORTED_FILE.md +17 -0
  117. package/docs/errors/E_USAGE.md +17 -0
  118. package/docs/errors/E_WRITE_IN_READ_MODE.md +17 -0
  119. package/docs/errors/E_WRITE_NOT_ALLOWED.md +17 -0
  120. package/docs/errors/W_BLUEPRINT_DOWNGRADE.md +17 -0
  121. package/docs/errors/W_CODEC_MISMATCH.md +18 -0
  122. package/docs/errors/W_INCOMPLETE.md +19 -0
  123. package/docs/errors/W_JSON_FIELDTYPE.md +17 -0
  124. package/docs/errors/W_KEY_COLLISION.md +17 -0
  125. package/docs/errors/W_LARGE_SCOPE.md +23 -0
  126. package/docs/errors/W_LIMIT_HEADROOM.md +19 -0
  127. package/docs/errors/W_LIMIT_UNREADABLE.md +17 -0
  128. package/docs/errors/W_MODE_SHADOWED.md +17 -0
  129. package/docs/errors/W_OVERRIDE_OPTION.md +17 -0
  130. package/docs/errors/W_PIN_EXPIRES.md +17 -0
  131. package/docs/errors/W_PREFIX.md +17 -0
  132. package/docs/errors/W_RATE_HEADERS.md +21 -0
  133. package/docs/errors/W_RATE_LIMIT.md +17 -0
  134. package/docs/errors/W_UNADDRESSABLE_NAME.md +21 -0
  135. package/docs/errors/W_UNFINISHED_APPLY.md +19 -0
  136. package/docs/errors/W_UNRESOLVED.md +17 -0
  137. package/docs/errors/W_UNSUPPORTED_TYPE.md +19 -0
  138. package/docs/errors/W_UNVERIFIED.md +17 -0
  139. package/docs/plan.md +85 -0
  140. package/docs/pull.md +83 -0
  141. package/docs/rm.md +44 -0
  142. package/docs/snapshot.md +52 -0
  143. package/docs/state.md +37 -0
  144. package/docs/targets.md +58 -0
  145. package/package.json +86 -0
@@ -0,0 +1,58 @@
1
+ # Targets
2
+
3
+ A target is a named HubSpot portal under `targets` in `kalup.config.ts`. Call it a target, never an environment.
4
+
5
+ This page is the reference. For the walk-through with examples, see [Targets and credentials](https://kalup.dev/docs/concepts/targets-and-credentials) on the website.
6
+
7
+ ```ts
8
+ targets: {
9
+ sandbox: { portalId: 1111111, credentials: { read: { env: 'HUBSPOT_SANDBOX_KEY' } } },
10
+ production: {
11
+ portalId: 2222222,
12
+ protected: true,
13
+ credentials: { read: { env: 'HUBSPOT_PROD_READ_KEY' } },
14
+ overrides: { 'property:harvest/picked_on': { name: 'pickedon' } },
15
+ },
16
+ },
17
+ ```
18
+
19
+ A target may not be named `config` (`E_TARGET_NAME`). A name carries no meaning: protection and drift come from the fields below.
20
+
21
+ ## Choosing a target
22
+
23
+ `pull`, `plan` and `snapshot` run against one target, picked after the config validates and before any request:
24
+
25
+ 1. `--target <name>`. An undeclared name is `E_UNKNOWN_TARGET`, exit 3, with no fallback.
26
+ 2. Else `defaultTarget`, a top-level string in `kalup.config.ts`. One that names no declared target is `E_DEFAULT_TARGET`, exit 3.
27
+ 3. Else the only target.
28
+ 4. Several targets and none selected: at a terminal (stdin and stderr are terminals, no `--json`, no `CI`), Kalup lists the names and portal IDs and asks; cancelling is `E_CANCELLED`, exit 1. Otherwise `E_TARGET_REQUIRED`, exit 1; an agent should ask the user which one.
29
+ 5. No targets: `E_NO_TARGETS`, exit 3.
30
+
31
+ The first of several targets is never chosen, and no choice is remembered. Text output names the target and how it was picked: `Target sandbox, portal 1111111 (defaultTarget)`.
32
+
33
+ ## Portal pin and guard
34
+
35
+ `portalId` is required, a positive integer (`E_PORTAL_ID`): the Hub ID from the HubSpot account menu. Two targets may not pin one portal (`E_DUPLICATE_PORTAL`). Every command that reads a target first checks the account-info of its key against the pin. A mismatch is `E_TARGET_PORTAL_MISMATCH`, exit 4, and nothing more is sent with that key.
36
+
37
+ ## Keys
38
+
39
+ `credentials.read.env` names the variable that holds the read key. Without `credentials` it is `HUBSPOT_SERVICE_KEY`, which `init` always reads. The key comes from the environment, else from the project's `.env`. A missing key is `E_MISSING_KEY`. No output carries a key.
40
+
41
+ The key goes out as `Authorization: Bearer`. `init` prints the read scopes the pull scope needs; `status` checks each. Both recommend one `crm.objects.<object>.read` scope too: Limits Tracking answered 403 to `crm.schemas.*` scopes alone and 200 with `crm.objects.companies.read` added (developer test account, 2026-09-29); without it `plan` cannot check the property limit (`W_LIMIT_UNREADABLE`). `credentials.write` names the key apply, `state rebuild --write` and `target rebind` use (apply.md); without it they use the read key. That key needs the read scopes and `crm.schemas.<object>.write` per object (`crm.schemas.custom.write` for custom objects), which `init` and `status` list. Neither checks them: read commands never resolve the write key, and no request can check a write scope.
42
+
43
+ ## Overrides
44
+
45
+ `overrides` is keyed by address: `property:<object>/<name>`, `group:<object>/<name>` or `object:<name>`. A key that is not an address in config is `E_UNKNOWN_OVERRIDE`. Any field other than these four is `E_NOT_DATA`:
46
+
47
+ - `name: '<portal name>'`: the resource's internal name in this portal. Every read uses it; `plan` blocks it when the portal lacks it. `E_OVERRIDE_AMBIGUOUS` when the portal holds both names; `E_OVERRIDE_NAME` when two addresses would read one portal resource.
48
+ - `skip: true`: left out on this target by every read, a group with its config properties.
49
+ - `definition: {...}`: the fields that differ on this target (config.md).
50
+ - `lookup`: no lookup resource is managed yet; `plan` blocks the resource, `compare` reports it unknown.
51
+
52
+ ## Policy
53
+
54
+ `protected: true` marks a portal that accepts only saved plans, not covered by `--yes`. `init` writes it for a `STANDARD` account; with config silent, only test portals, sandboxes and app developer accounts are unprotected. `drift` (`'hold'` or `'overwrite'`, default hold) acts only where state holds a base; `adopt` (same values, default hold) decides a unit with no base, as on a first adoption (plan.md). `allowDestroy` (default false) lets a destroy tombstone or takeover delete in this portal. `yesLimit` (0 to 1000, default 25) caps what `--yes` covers; `0` turns it off. `mode` and `objects: { <object>: { mode } }` set takeover per target (config.md). All of them enter the plan's approval digest, and none is inherited from the project or an object but `mode`.
55
+
56
+ ## Rebind
57
+
58
+ `kalup target rebind <target> --portal <id>` points a target at a recreated test portal or sandbox that no other target pins (`E_DUPLICATE_PORTAL`) and the target's write key belongs to; state.md has the steps. Plans saved for the old portal are refused (`E_PLAN_DESTINATION`).
package/package.json ADDED
@@ -0,0 +1,86 @@
1
+ {
2
+ "name": "kalup",
3
+ "version": "0.1.0",
4
+ "description": "Configuration as code for HubSpot: pull, compare, plan and apply properties and property groups",
5
+ "keywords": [
6
+ "hubspot",
7
+ "crm",
8
+ "configuration-as-code",
9
+ "infrastructure-as-code",
10
+ "iac",
11
+ "cli",
12
+ "typescript",
13
+ "schema",
14
+ "devops"
15
+ ],
16
+ "homepage": "https://kalup.dev",
17
+ "bugs": {
18
+ "url": "https://github.com/scopiousdigital/kalup/issues"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/scopiousdigital/kalup.git",
23
+ "directory": "packages/cli"
24
+ },
25
+ "license": "Apache-2.0",
26
+ "author": "Scopious (https://scopious.dev)",
27
+ "type": "module",
28
+ "exports": {
29
+ "./schemas/*.json": "./dist/schemas/*.json"
30
+ },
31
+ "bin": {
32
+ "kalup": "./bin/kalup.mjs"
33
+ },
34
+ "files": [
35
+ "bin",
36
+ "dist",
37
+ "!dist/build-stamp.json",
38
+ "docs",
39
+ "LICENSE",
40
+ "NOTICE"
41
+ ],
42
+ "oclif": {
43
+ "bin": "kalup",
44
+ "commands": {
45
+ "identifier": "COMMANDS",
46
+ "strategy": "explicit",
47
+ "target": "./dist/commands.mjs"
48
+ },
49
+ "description": "Kalup: configuration as code for HubSpot.",
50
+ "dirname": "kalup",
51
+ "topicSeparator": " ",
52
+ "topics": {
53
+ "blueprint": {
54
+ "description": "Upgrade a blueprint added with kalup add."
55
+ },
56
+ "state": {
57
+ "description": "Inspect and rebuild the state file of a target's portal."
58
+ },
59
+ "target": {
60
+ "description": "Change a target's portal."
61
+ }
62
+ }
63
+ },
64
+ "dependencies": {
65
+ "@oclif/core": "^5.0.0",
66
+ "@kalup/core": "0.1.0"
67
+ },
68
+ "devDependencies": {
69
+ "tsdown": "^0.23.0",
70
+ "vitest": "^5.0.1",
71
+ "@kalup/tsconfig": "0.0.0",
72
+ "@kalup/engine": "0.0.0"
73
+ },
74
+ "engines": {
75
+ "node": ">=22.13.1"
76
+ },
77
+ "publishConfig": {
78
+ "access": "public"
79
+ },
80
+ "scripts": {
81
+ "build": "tsdown",
82
+ "test": "vitest run",
83
+ "test:live": "vitest run --config vitest.live.config.ts",
84
+ "typecheck": "tsc --noEmit"
85
+ }
86
+ }