workpeg 0.161.0__tar.gz → 0.162.0__tar.gz

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 (158) hide show
  1. {workpeg-0.161.0/src/workpeg.egg-info → workpeg-0.162.0}/PKG-INFO +1 -1
  2. {workpeg-0.161.0 → workpeg-0.162.0}/pyproject.toml +1 -1
  3. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/agents/AGENTS.md +1 -0
  4. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/build.py +4 -2
  5. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/compiler/ast_parser.py +8 -0
  6. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/workpeg-runtime.js +142 -26
  7. {workpeg-0.161.0 → workpeg-0.162.0/src/workpeg.egg-info}/PKG-INFO +1 -1
  8. {workpeg-0.161.0 → workpeg-0.162.0}/LICENSE +0 -0
  9. {workpeg-0.161.0 → workpeg-0.162.0}/MANIFEST.in +0 -0
  10. {workpeg-0.161.0 → workpeg-0.162.0}/README.md +0 -0
  11. {workpeg-0.161.0 → workpeg-0.162.0}/setup.cfg +0 -0
  12. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/__init__.py +0 -0
  13. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/auth.py +0 -0
  14. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/build.py +0 -0
  15. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/cdn.py +0 -0
  16. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/cli.py +0 -0
  17. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/config.py +0 -0
  18. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/context.py +0 -0
  19. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/create_new.py +0 -0
  20. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/doctor.py +0 -0
  21. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/function_base.py +0 -0
  22. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/function_check.py +0 -0
  23. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/function_envelopes.py +0 -0
  24. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/function_local.py +0 -0
  25. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/listen.py +0 -0
  26. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/project.py +0 -0
  27. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/project_submit.py +0 -0
  28. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/run.py +0 -0
  29. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/runtime.py +0 -0
  30. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/sandbox/__init__.py +0 -0
  31. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/sandbox/docker_driver.py +0 -0
  32. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/sandbox/driver.py +0 -0
  33. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/starter.py +0 -0
  34. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/submit.py +0 -0
  35. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/target_sdk.py +0 -0
  36. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/__init__.py +0 -0
  37. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/agents/CLAUDE.md +0 -0
  38. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/functions/Dockerfile +0 -0
  39. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/functions/LICENSE +0 -0
  40. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/functions/README.md +0 -0
  41. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/functions/app/__init__.py +0 -0
  42. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/functions/app/main.py +0 -0
  43. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/functions/requirements.txt +0 -0
  44. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/functions/wheels/README.txt +0 -0
  45. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/project/README.md +0 -0
  46. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/project/function/Dockerfile +0 -0
  47. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/project/function/app/__init__.py +0 -0
  48. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/project/function/app/main.py +0 -0
  49. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/project/function/requirements.txt +0 -0
  50. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/project/function/wheels/README.txt +0 -0
  51. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/project/workpeg.json +0 -0
  52. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/starter/app_shell.py +0 -0
  53. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/starter/components.py +0 -0
  54. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/starter/main.py +0 -0
  55. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/starter/pages/__init__.py +0 -0
  56. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/starter/pages/customer.py +0 -0
  57. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/starter/pages/customers.py +0 -0
  58. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/starter/pages/home.py +0 -0
  59. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/templates/starter/pages/not_found.py +0 -0
  60. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/terminal.py +0 -0
  61. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/__init__.py +0 -0
  62. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/actions.py +0 -0
  63. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/actions_manifest.py +0 -0
  64. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/app.py +0 -0
  65. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/calendar.py +0 -0
  66. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/compiler/__init__.py +0 -0
  67. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/compiler/ir.py +0 -0
  68. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/compiler/js_generator.py +0 -0
  69. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/compiler/rtc_checks.py +0 -0
  70. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/compiler/rtc_tables.py +0 -0
  71. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/create.py +0 -0
  72. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/dates.py +0 -0
  73. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/dev_refused_names.json +0 -0
  74. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/devmode.py +0 -0
  75. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/devserve.py +0 -0
  76. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/devsite.py +0 -0
  77. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/fake_cloud.py +0 -0
  78. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/minify.py +0 -0
  79. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/render_nodes.py +0 -0
  80. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/renderers_manifest.py +0 -0
  81. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/rtc.py +0 -0
  82. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/ai-concurrent-replies.md +0 -0
  83. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/ai-prompt-queue.md +0 -0
  84. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/ai-question-frame.md +0 -0
  85. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/ai-subagent-frame.md +0 -0
  86. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/ai.js +0 -0
  87. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/editor.js +0 -0
  88. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/fonts/OFL.txt +0 -0
  89. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/fonts/geist-italic-cyrillic-ext.af944491.woff2 +0 -0
  90. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/fonts/geist-italic-cyrillic.88be6946.woff2 +0 -0
  91. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/fonts/geist-italic-latin-ext.370a8962.woff2 +0 -0
  92. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/fonts/geist-italic-latin.7611b95c.woff2 +0 -0
  93. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/fonts/geist-italic-vietnamese.8dfcf303.woff2 +0 -0
  94. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/fonts/geist-normal-cyrillic-ext.b7a545bb.woff2 +0 -0
  95. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/fonts/geist-normal-cyrillic.6129fc85.woff2 +0 -0
  96. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/fonts/geist-normal-latin-ext.58a6b173.woff2 +0 -0
  97. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/fonts/geist-normal-latin.9b6f5ff4.woff2 +0 -0
  98. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/fonts/geist-normal-vietnamese.f689f638.woff2 +0 -0
  99. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/icons.css.gz +0 -0
  100. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/overlay.js +0 -0
  101. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/pegment.css +0 -0
  102. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/rtc.js +0 -0
  103. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/runtime/scaffold.js +0 -0
  104. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/scaffold.py +0 -0
  105. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/search_manifest.py +0 -0
  106. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/serve.py +0 -0
  107. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/skills_manifest.py +0 -0
  108. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/state.py +0 -0
  109. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/validators.py +0 -0
  110. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/verify.py +0 -0
  111. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/watcher.py +0 -0
  112. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/widgets/__init__.py +0 -0
  113. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/widgets/base.py +0 -0
  114. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/widgets/canvas.py +0 -0
  115. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/widgets/display.py +0 -0
  116. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/widgets/fields.py +0 -0
  117. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/widgets/forms.py +0 -0
  118. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/widgets/futures.py +0 -0
  119. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/widgets/gestures.py +0 -0
  120. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/widgets/interactive.py +0 -0
  121. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/widgets/layout.py +0 -0
  122. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/ui/widgets/pickers.py +0 -0
  123. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg/utils.py +0 -0
  124. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg.egg-info/SOURCES.txt +0 -0
  125. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg.egg-info/dependency_links.txt +0 -0
  126. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg.egg-info/entry_points.txt +0 -0
  127. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg.egg-info/requires.txt +0 -0
  128. {workpeg-0.161.0 → workpeg-0.162.0}/src/workpeg.egg-info/top_level.txt +0 -0
  129. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_agents_guide.py +0 -0
  130. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_auth.py +0 -0
  131. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_build.py +0 -0
  132. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_cdn.py +0 -0
  133. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_cdn_publish.py +0 -0
  134. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_changelog.py +0 -0
  135. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_changelog_guard.py +0 -0
  136. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_cli.py +0 -0
  137. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_config.py +0 -0
  138. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_context.py +0 -0
  139. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_create_new.py +0 -0
  140. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_dev_functions_wire.py +0 -0
  141. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_dev_install_example.py +0 -0
  142. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_doctor.py +0 -0
  143. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_function_check.py +0 -0
  144. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_function_envelopes.py +0 -0
  145. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_function_listen.py +0 -0
  146. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_pegfn_base.py +0 -0
  147. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_project_create.py +0 -0
  148. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_project_submit.py +0 -0
  149. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_release_script.py +0 -0
  150. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_run.py +0 -0
  151. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_run_cli.py +0 -0
  152. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_runtime.py +0 -0
  153. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_runtime_invoke_key.py +0 -0
  154. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_submit.py +0 -0
  155. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_target_sdk.py +0 -0
  156. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_utils.py +0 -0
  157. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_version.py +0 -0
  158. {workpeg-0.161.0 → workpeg-0.162.0}/tests/test_watch_pipeline.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: workpeg
3
- Version: 0.161.0
3
+ Version: 0.162.0
4
4
  Summary: Workpeg function runtime and SDK
5
5
  Author-email: Workpeg <support@workpeg.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "workpeg"
7
- version = "0.161.0"
7
+ version = "0.162.0"
8
8
  description = "Workpeg function runtime and SDK"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -619,6 +619,7 @@ namespace, and must be awaited.
619
619
  | `await workpeg.add_row(uuid, row)`, `add_rows(uuid, rows)` | Adds one row, or a list |
620
620
  | `await workpeg.update_row(uuid, row_id, patch)` | Updates a row. `data` is replaced whole: copy every column the row has, then change yours (`CustomerPage.save`) |
621
621
  | `await workpeg.delete_row(uuid, row_id)` | Deletes a row |
622
+ | `await workpeg.create_inbound_key(uuid, name)`, `get_inbound_keys(uuid)`, `revoke_inbound_key(uuid, key_id)` | A write-only key an outside service adds rows with (the `inbound` scope). The key is shown once: never keep it in `State` or a row |
622
623
  | `await workpeg.first_business()` | The person's first business uuid, or `""` |
623
624
 
624
625
  Rules:
@@ -1132,8 +1132,10 @@ def _dev_section(source: Path) -> "dict | None":
1132
1132
  #: Every scope a manifest may declare: the api's ``core.peg_scopes.
1133
1133
  #: KNOWN_SCOPES``, which must list a scope before any peg can reach it.
1134
1134
  #: ``files`` opens the business's Drive, ``mail`` its mail admin, ``calls``
1135
- #: ``people/`` and ``signals/`` (``workpeg.ui.rtc``'s signaling).
1136
- KNOWN_SCOPES = ("calls", "files", "mail")
1135
+ #: ``people/`` and ``signals/`` (``workpeg.ui.rtc``'s signaling), and
1136
+ #: ``inbound`` lets the peg's page mint inbound keys on its own tables: a
1137
+ #: write-only key an outside service uses to add rows (docs/tables.md).
1138
+ KNOWN_SCOPES = ("calls", "files", "inbound", "mail")
1137
1139
 
1138
1140
 
1139
1141
  def _scopes_section(source: Path) -> "list | None":
@@ -159,6 +159,14 @@ _WORKPEG_TABLE_HELPERS = {
159
159
  "add_rows": (2, 2, "workpeg.add_rows(table_uuid, rows)"),
160
160
  "update_row": (3, 3, "workpeg.update_row(table_uuid, row_id, patch)"),
161
161
  "delete_row": (2, 2, "workpeg.delete_row(table_uuid, row_id)"),
162
+ # Inbound keys: a write-only credential an outside service uses to ADD
163
+ # rows to one of the peg's tables. Minting needs the `inbound` scope,
164
+ # which the api judges by Origin; these only build the request.
165
+ "create_inbound_key": (
166
+ 2, 2, "workpeg.create_inbound_key(table_uuid, name)"),
167
+ "get_inbound_keys": (1, 1, "workpeg.get_inbound_keys(table_uuid)"),
168
+ "revoke_inbound_key": (
169
+ 2, 2, "workpeg.revoke_inbound_key(table_uuid, key_id)"),
162
170
  }
163
171
 
164
172
  # Curated session/chrome helpers on workpeg.* — no URL, no arbitrary reach.
@@ -581,24 +581,54 @@
581
581
  // header) — the platform scopes the visible tables to the calling Peg.
582
582
  // workpeg.get_tables / get_table / create_table / update_table /
583
583
  // delete_table / get_rows / get_row / add_row / add_rows / update_row /
584
- // delete_row in Python compile here.
584
+ // delete_row, and create_inbound_key / get_inbound_keys /
585
+ // revoke_inbound_key below, in Python compile here.
586
+
587
+ // One path segment from a caller's id. encodeURIComponent keeps "." and
588
+ // "..", and fetch resolves a dot segment as it builds the request, so
589
+ // delete_row(t, "..") would DELETE the table itself and
590
+ // revoke_inbound_key(t, "..") the same. A slash or backslash is refused
591
+ // too: the api's server decodes "%2F" before it routes, so an encoded
592
+ // slash can still split the segment there. The id is refused, never
593
+ // repaired, and the value is kept out of the message because it is data.
594
+ Workpeg._wpSegment = function (value, what) {
595
+ var s = String(value);
596
+ if (s === "." || s === ".." || /[\/\\]/.test(s)) {
597
+ throw new Error(
598
+ "workpeg: a " + what + " can't be \".\", \"..\" or hold a slash."
599
+ );
600
+ }
601
+ return encodeURIComponent(s);
602
+ };
603
+
604
+ // A table helper answers with a promise, a refused id included, so
605
+ // `await` in the compiled method catches it like any failed request and
606
+ // nothing is sent.
607
+ Workpeg._wpCall = function (build) {
608
+ try {
609
+ return build();
610
+ } catch (e) {
611
+ return Promise.reject(e);
612
+ }
613
+ };
585
614
 
586
615
  // Build "/v1/businesses/<biz>/tables/[<uuid>/[tail]]". Every dynamic segment
587
- // is URI-encoded, so an id can't smuggle extra path segments or a query.
616
+ // is URI-encoded, so an id can't smuggle extra path segments or a query,
617
+ // and a table uuid that is a dot segment or holds a slash throws.
588
618
  Workpeg._wpTablesUrl = function (tableUuid, tail) {
589
619
  var url =
590
620
  "/v1/businesses/" +
591
621
  encodeURIComponent(Workpeg._businessIdFromPath()) +
592
622
  "/tables/";
593
623
  if (tableUuid != null && tableUuid !== "") {
594
- url += encodeURIComponent(String(tableUuid)) + "/";
624
+ url += Workpeg._wpSegment(tableUuid, "table uuid") + "/";
595
625
  }
596
626
  return tail ? url + tail : url;
597
627
  };
598
628
 
599
629
  Workpeg._wpRowUrl = function (tableUuid, rowId) {
600
630
  return Workpeg._wpTablesUrl(
601
- tableUuid, "rows/" + encodeURIComponent(String(rowId)) + "/"
631
+ tableUuid, "rows/" + Workpeg._wpSegment(rowId, "row id") + "/"
602
632
  );
603
633
  };
604
634
 
@@ -614,7 +644,9 @@
614
644
 
615
645
  // workpeg.get_table(table_uuid) — one table (columns included).
616
646
  Workpeg.wpGetTable = function (tableUuid) {
617
- return Workpeg.wpGetProtected(Workpeg._wpTablesUrl(tableUuid));
647
+ return Workpeg._wpCall(function () {
648
+ return Workpeg.wpGetProtected(Workpeg._wpTablesUrl(tableUuid));
649
+ });
618
650
  };
619
651
 
620
652
  // workpeg.create_table(table) — create a table from a definition
@@ -626,12 +658,16 @@
626
658
  // workpeg.update_table(table_uuid, patch) — partial update; only the fields
627
659
  // present in `patch` change.
628
660
  Workpeg.wpUpdateTable = function (tableUuid, patch) {
629
- return Workpeg.wpPatchProtected(Workpeg._wpTablesUrl(tableUuid), patch);
661
+ return Workpeg._wpCall(function () {
662
+ return Workpeg.wpPatchProtected(Workpeg._wpTablesUrl(tableUuid), patch);
663
+ });
630
664
  };
631
665
 
632
666
  // workpeg.delete_table(table_uuid) — delete the table (and its rows).
633
667
  Workpeg.wpDeleteTable = function (tableUuid) {
634
- return Workpeg.wpDeleteProtected(Workpeg._wpTablesUrl(tableUuid));
668
+ return Workpeg._wpCall(function () {
669
+ return Workpeg.wpDeleteProtected(Workpeg._wpTablesUrl(tableUuid));
670
+ });
635
671
  };
636
672
 
637
673
  // workpeg.get_rows(table_uuid[, {limit, offset}]) — the table's rows,
@@ -639,45 +675,125 @@
639
675
  // (the standard for unbounded tables); the response is a bare array either
640
676
  // way — no pagination envelope. Non-numeric or negative values are dropped.
641
677
  Workpeg.wpGetRows = function (tableUuid, opts) {
642
- var url = Workpeg._wpTablesUrl(tableUuid, "rows/");
643
- var qs = [];
644
- if (opts) {
645
- ["limit", "offset"].forEach(function (k) {
646
- var v = Number(opts[k]);
647
- if (isFinite(v) && v >= 0) qs.push(k + "=" + Math.floor(v));
648
- });
649
- }
650
- if (qs.length) url += "?" + qs.join("&");
651
- return Workpeg.wpGetProtected(url);
678
+ return Workpeg._wpCall(function () {
679
+ var url = Workpeg._wpTablesUrl(tableUuid, "rows/");
680
+ var qs = [];
681
+ if (opts) {
682
+ ["limit", "offset"].forEach(function (k) {
683
+ var v = Number(opts[k]);
684
+ if (isFinite(v) && v >= 0) qs.push(k + "=" + Math.floor(v));
685
+ });
686
+ }
687
+ if (qs.length) url += "?" + qs.join("&");
688
+ return Workpeg.wpGetProtected(url);
689
+ });
652
690
  };
653
691
 
654
692
  // workpeg.get_row(table_uuid, row_id) — one row.
655
693
  Workpeg.wpGetRow = function (tableUuid, rowId) {
656
- return Workpeg.wpGetProtected(Workpeg._wpRowUrl(tableUuid, rowId));
694
+ return Workpeg._wpCall(function () {
695
+ return Workpeg.wpGetProtected(Workpeg._wpRowUrl(tableUuid, rowId));
696
+ });
657
697
  };
658
698
 
659
699
  // workpeg.add_row(table_uuid, row) — create a row ({data, position, …}).
660
700
  Workpeg.wpAddRow = function (tableUuid, row) {
661
- return Workpeg.wpPostProtected(
662
- Workpeg._wpTablesUrl(tableUuid, "rows/"), row
663
- );
701
+ return Workpeg._wpCall(function () {
702
+ return Workpeg.wpPostProtected(
703
+ Workpeg._wpTablesUrl(tableUuid, "rows/"), row
704
+ );
705
+ });
664
706
  };
665
707
 
666
708
  // workpeg.add_rows(table_uuid, rows) — bulk-create rows from a list.
667
709
  Workpeg.wpAddRows = function (tableUuid, rows) {
668
- return Workpeg.wpPostProtected(
669
- Workpeg._wpTablesUrl(tableUuid, "bulk-create/"), rows
670
- );
710
+ return Workpeg._wpCall(function () {
711
+ return Workpeg.wpPostProtected(
712
+ Workpeg._wpTablesUrl(tableUuid, "bulk-create/"), rows
713
+ );
714
+ });
671
715
  };
672
716
 
673
717
  // workpeg.update_row(table_uuid, row_id, patch) — partial update.
674
718
  Workpeg.wpUpdateRow = function (tableUuid, rowId, patch) {
675
- return Workpeg.wpPatchProtected(Workpeg._wpRowUrl(tableUuid, rowId), patch);
719
+ return Workpeg._wpCall(function () {
720
+ return Workpeg.wpPatchProtected(
721
+ Workpeg._wpRowUrl(tableUuid, rowId), patch
722
+ );
723
+ });
676
724
  };
677
725
 
678
726
  // workpeg.delete_row(table_uuid, row_id) — delete the row.
679
727
  Workpeg.wpDeleteRow = function (tableUuid, rowId) {
680
- return Workpeg.wpDeleteProtected(Workpeg._wpRowUrl(tableUuid, rowId));
728
+ return Workpeg._wpCall(function () {
729
+ return Workpeg.wpDeleteProtected(Workpeg._wpRowUrl(tableUuid, rowId));
730
+ });
731
+ };
732
+
733
+ // ------------------------------------------------- workpeg.* inbound keys
734
+ //
735
+ // An inbound key lets an outside service ADD rows to one of the peg's
736
+ // tables, and do nothing else. The api decides who may mint one (a
737
+ // person's own session, from the peg's own origin, the peg holding the
738
+ // `inbound` scope); these helpers only build the request. The key that
739
+ // create_inbound_key resolves to is shown once and never again, so it is
740
+ // never cached, logged or kept here.
741
+ //
742
+ // A missing table or key id is refused before any request: an empty
743
+ // segment would leave a URL that names a different resource (a table
744
+ // called "inbound-keys", or the list instead of one key). A key id is
745
+ // only ever what the api hands out, 32 hex digits or the same as a
746
+ // dashed uuid, so anything else is refused rather than sent: a key id
747
+ // can come from an outside service's answer, and ".." from there would
748
+ // otherwise revoke nothing and DELETE the table.
749
+ Workpeg._wpKeyId = /^(?:[0-9a-f]{32}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i;
750
+
751
+ Workpeg._wpInboundKeysUrl = function (tableUuid, keyId) {
752
+ if (tableUuid == null || String(tableUuid) === "") {
753
+ throw new Error("workpeg inbound keys need a table uuid.");
754
+ }
755
+ var tail = "inbound-keys/";
756
+ if (arguments.length > 1) {
757
+ if (keyId == null || String(keyId) === "") {
758
+ throw new Error("workpeg.revoke_inbound_key() needs a key id.");
759
+ }
760
+ if (!Workpeg._wpKeyId.test(String(keyId))) {
761
+ throw new Error(
762
+ "workpeg.revoke_inbound_key() needs a key id of 32 hex digits"
763
+ + " or a uuid."
764
+ );
765
+ }
766
+ tail += Workpeg._wpSegment(keyId, "key id") + "/";
767
+ }
768
+ return Workpeg._wpTablesUrl(tableUuid, tail);
769
+ };
770
+
771
+ // workpeg.create_inbound_key(table_uuid, name) -> {id, name, key,
772
+ // created_at}. `key` is returned this once.
773
+ Workpeg.wpCreateInboundKey = function (tableUuid, name) {
774
+ return Workpeg._wpCall(function () {
775
+ return Workpeg.wpPostProtected(
776
+ Workpeg._wpInboundKeysUrl(tableUuid), { name: name }
777
+ );
778
+ });
779
+ };
780
+
781
+ // workpeg.get_inbound_keys(table_uuid) -> [{id, name, created_at,
782
+ // last_used_at, uses, revoked, created_by}]; never a key's secret.
783
+ Workpeg.wpGetInboundKeys = function (tableUuid) {
784
+ return Workpeg._wpCall(function () {
785
+ return Workpeg.wpGetProtected(Workpeg._wpInboundKeysUrl(tableUuid));
786
+ });
787
+ };
788
+
789
+ // workpeg.revoke_inbound_key(table_uuid, key_id) -> {revoked: true}. The
790
+ // api answers 200 with JSON (not 204), and a second revoke is the same.
791
+ Workpeg.wpRevokeInboundKey = function (tableUuid, keyId) {
792
+ return Workpeg._wpCall(function () {
793
+ return Workpeg.wpDeleteProtected(
794
+ Workpeg._wpInboundKeysUrl(tableUuid, keyId)
795
+ );
796
+ });
681
797
  };
682
798
 
683
799
  // ----------------------------------------------------------------- auth gate
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: workpeg
3
- Version: 0.161.0
3
+ Version: 0.162.0
4
4
  Summary: Workpeg function runtime and SDK
5
5
  Author-email: Workpeg <support@workpeg.com>
6
6
  License: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes