@thehumanpatternlab/hpl 1.0.0 → 1.0.2

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.
@@ -4,10 +4,10 @@
4
4
  import { Command } from "commander";
5
5
  import { writeHuman, writeJson } from "../io.js";
6
6
  import { z } from "zod";
7
- import { getAlphaIntent } from "../contract/intents";
8
- import { ok, err } from "../contract/envelope";
9
- import { EXIT } from "../contract/exitCodes";
10
- import { getJson, HttpError } from "../http/client";
7
+ import { getAlphaIntent } from "../contract/intents.js";
8
+ import { ok, err } from "../contract/envelope.js";
9
+ import { EXIT } from "../contract/exitCodes.js";
10
+ import { getJson, HttpError } from "../http/client.js";
11
11
  const HealthSchema = z.object({
12
12
  status: z.string(),
13
13
  dbPath: z.string().optional(),
@@ -86,7 +86,7 @@ export async function runNotesCreate(options, commandName = "notes.create") {
86
86
  const payload = {
87
87
  slug: options.slug,
88
88
  title: options.title,
89
- markdown,
89
+ content_markdown: markdown,
90
90
  locale: options.locale,
91
91
  subtitle: options.subtitle,
92
92
  summary: options.summary,
@@ -110,7 +110,7 @@ export async function runNotesCreate(options, commandName = "notes.create") {
110
110
  }
111
111
  // Make API request
112
112
  try {
113
- const response = await postJson("/lab-notes/upsert", parsed.data, token);
113
+ const response = await postJson("/admin/notes", parsed.data, token);
114
114
  return {
115
115
  envelope: ok(commandName, intent, {
116
116
  slug: response.slug,
@@ -35,7 +35,7 @@ async function upsertNote(baseUrl, token, note, locale) {
35
35
  const payload = {
36
36
  slug: note.slug,
37
37
  title: note.attributes.title,
38
- markdown: note.markdown,
38
+ content_markdown: note.markdown,
39
39
  locale,
40
40
  // Optional fields if your note parser provides them
41
41
  subtitle: note.attributes.subtitle,
@@ -50,7 +50,7 @@ async function upsertNote(baseUrl, token, note, locale) {
50
50
  if (!parsed.success) {
51
51
  throw new Error(`Invalid LabNoteUpsertPayload: ${parsed.error.message}`);
52
52
  }
53
- return httpJson({ baseUrl, token }, "POST", "/lab-notes/upsert", parsed.data);
53
+ return httpJson({ baseUrl, token }, "POST", "/admin/notes", parsed.data);
54
54
  }
55
55
  /**
56
56
  * Commander: `hpl notes sync`
@@ -93,7 +93,7 @@ export async function runNotesUpdate(options, commandName = "notes.update") {
93
93
  if (options.title)
94
94
  payload.title = options.title;
95
95
  if (markdown)
96
- payload.markdown = markdown;
96
+ payload.content_markdown = markdown;
97
97
  if (options.locale)
98
98
  payload.locale = options.locale;
99
99
  if (options.subtitle)
@@ -110,9 +110,9 @@ export async function runNotesUpdate(options, commandName = "notes.update") {
110
110
  payload.type = options.type;
111
111
  if (options.dept)
112
112
  payload.dept = options.dept;
113
- // The upsert endpoint requires title and markdown
113
+ // The upsert endpoint requires title and content_markdown
114
114
  // For an update operation, if these aren't provided, we should fetch the existing note first
115
- if (!payload.title || !payload.markdown) {
115
+ if (!payload.title || !payload.content_markdown) {
116
116
  return {
117
117
  envelope: err(commandName, intent, {
118
118
  code: "E_VALIDATION",
@@ -135,7 +135,7 @@ export async function runNotesUpdate(options, commandName = "notes.update") {
135
135
  }
136
136
  // Make API request
137
137
  try {
138
- const response = await postJson("/lab-notes/upsert", parsed.data, token);
138
+ const response = await postJson("/admin/notes", parsed.data, token);
139
139
  return {
140
140
  envelope: ok(commandName, intent, {
141
141
  slug: response.slug,
@@ -91,14 +91,15 @@ export const LabNoteDetailSchema = LabNoteViewSchema.extend({
91
91
  content_markdown: z.string().optional(), // API always includes it in your code, but keep optional for safety
92
92
  });
93
93
  /**
94
- * CLI → API payload for upsert (notes sync).
94
+ * CLI → API payload for upsert (notes sync and admin create/update).
95
+ * Uses content_markdown to match the API's field name.
95
96
  * Strict: our outbound contract.
96
97
  */
97
98
  export const LabNoteUpsertSchema = z
98
99
  .object({
99
100
  slug: z.string().min(1),
100
101
  title: z.string().min(1),
101
- markdown: z.string().min(1),
102
+ content_markdown: z.string().min(1),
102
103
  locale: z.string().optional(),
103
104
  subtitle: z.string().optional(),
104
105
  summary: z.string().optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thehumanpatternlab/hpl",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "AI-forward, automation-safe SDK and CLI for the Human Pattern Lab",
5
5
  "type": "module",
6
6
  "license": "MIT",