Skip to content

Commit 2179e68

Browse files
Bumping version to 3.0.2.
1 parent 8a028d2 commit 2179e68

File tree

6 files changed

+23
-136
lines changed

6 files changed

+23
-136
lines changed

docs/openapi.yaml

Lines changed: 6 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ paths:
153153
154154
Allows you to modify the content relative to a heading, block reference, or frontmatter field in your document.
155155
156+
Note that this API was changed in Version 3.0 of this extension and the earlier PATCH API is now deprecated. Requests made using the previous version of this API will continue to work until Version 4.0 is released. See https://github.com/coddingtonbear/obsidian-local-rest-api/wiki/Changes-to-PATCH-requests-between-versions-2.0-and-3.0 for more details and migration instructions.
157+
156158
# Examples
157159
158160
All of the below examples assume you have a document that looks like
@@ -276,38 +278,6 @@ paths:
276278
interpreting yoru `prepend` or `append` requests if you specify
277279
your data as JSON (particularly when appending, for example,
278280
list items).
279-
280-
# Upgrading from Version 2.0 (heading-based) to Version 3.0 (target-based) APIs
281-
282-
This API was changed in version 3.0 of Obsidian Local REST API to support making changes to your document relative to ["block references"](https://help.obsidian.md/Linking+notes+and+files/Internal+links#Link+to+a+block+in+a+note) and frontmatter fields in addition to headings within your document.
283-
Version 2.0 of this API (now undocumented) is still accessible as
284-
long as your incoming request specifies the `Heading` header and
285-
*does not* specify a `Target-Type` header. You should upgrade, though,
286-
to the current version of the API as support for the Version 2.0 API is
287-
now deprecated and will stop working in Version 4.0.
288-
289-
You can migrate to the current version of the API by following the below guidelines. The words "heading" and "header" both occur quite a lot in the below paragraphs so it may aid in your understanding if you keep in mind that "head**ing**" here refers to a heading existing within your markdown document and "head**er**" refers to an HTTP Header that you may set to a value as part of using this API.
290-
291-
1. Rename your `Heading` header to `Target`.
292-
2. Add a new `Target-Type` header having the value `heading`.
293-
3. Set the `Operation` header such that its value is `append` if you had either not set the `Content-Insertion-Position` header or had set it to `end`. Set it to `prepend` if you had set `Content-Insertion-Position` to `beginning`.
294-
4. If you had set `Content-Insertion-Ignore-Newline` to `true`, set the `Trim-Target-Whitespace` header value to `true` also.
295-
296-
Aside from the above, there is one important thing to keep in mind: while the obsolete version of this API allowed you to specify just the terminal heading (e.g. content under `### My Heading` could be addressed by setting the `Heading` header to `My Heading`), the current version of this API requires that you provide the full path to your target heading (i.e. instead of `My Heading`, you must find the parent second level heading and and its parent top level heading) delimited by `::`. If `::` appears in your heading, you can override that value by setting the `Target-Delimiter` header.
297-
298-
For example, if you had previously set `Heading` to `My Heading` for adding content to "MY CONTENT" in a document like:
299-
300-
```markdown
301-
# Some top-level heading
302-
303-
## Some second-level heading
304-
305-
### My Heading
306-
307-
MY CONTENT
308-
```
309-
310-
you should now set yoru `Target` heading to `Some top-level heading::Some second-level heading::My Heading`.
311281
parameters:
312282
- description: "Patch operation to perform"
313283
in: "header"
@@ -627,6 +597,8 @@ paths:
627597
628598
Allows you to modify the content relative to a heading, block reference, or frontmatter field in your document.
629599
600+
Note that this API was changed in Version 3.0 of this extension and the earlier PATCH API is now deprecated. Requests made using the previous version of this API will continue to work until Version 4.0 is released. See https://github.com/coddingtonbear/obsidian-local-rest-api/wiki/Changes-to-PATCH-requests-between-versions-2.0-and-3.0 for more details and migration instructions.
601+
630602
# Examples
631603
632604
All of the below examples assume you have a document that looks like
@@ -750,38 +722,6 @@ paths:
750722
interpreting yoru `prepend` or `append` requests if you specify
751723
your data as JSON (particularly when appending, for example,
752724
list items).
753-
754-
# Upgrading from Version 2.0 (heading-based) to Version 3.0 (target-based) APIs
755-
756-
This API was changed in version 3.0 of Obsidian Local REST API to support making changes to your document relative to ["block references"](https://help.obsidian.md/Linking+notes+and+files/Internal+links#Link+to+a+block+in+a+note) and frontmatter fields in addition to headings within your document.
757-
Version 2.0 of this API (now undocumented) is still accessible as
758-
long as your incoming request specifies the `Heading` header and
759-
*does not* specify a `Target-Type` header. You should upgrade, though,
760-
to the current version of the API as support for the Version 2.0 API is
761-
now deprecated and will stop working in Version 4.0.
762-
763-
You can migrate to the current version of the API by following the below guidelines. The words "heading" and "header" both occur quite a lot in the below paragraphs so it may aid in your understanding if you keep in mind that "head**ing**" here refers to a heading existing within your markdown document and "head**er**" refers to an HTTP Header that you may set to a value as part of using this API.
764-
765-
1. Rename your `Heading` header to `Target`.
766-
2. Add a new `Target-Type` header having the value `heading`.
767-
3. Set the `Operation` header such that its value is `append` if you had either not set the `Content-Insertion-Position` header or had set it to `end`. Set it to `prepend` if you had set `Content-Insertion-Position` to `beginning`.
768-
4. If you had set `Content-Insertion-Ignore-Newline` to `true`, set the `Trim-Target-Whitespace` header value to `true` also.
769-
770-
Aside from the above, there is one important thing to keep in mind: while the obsolete version of this API allowed you to specify just the terminal heading (e.g. content under `### My Heading` could be addressed by setting the `Heading` header to `My Heading`), the current version of this API requires that you provide the full path to your target heading (i.e. instead of `My Heading`, you must find the parent second level heading and and its parent top level heading) delimited by `::`. If `::` appears in your heading, you can override that value by setting the `Target-Delimiter` header.
771-
772-
For example, if you had previously set `Heading` to `My Heading` for adding content to "MY CONTENT" in a document like:
773-
774-
```markdown
775-
# Some top-level heading
776-
777-
## Some second-level heading
778-
779-
### My Heading
780-
781-
MY CONTENT
782-
```
783-
784-
you should now set yoru `Target` heading to `Some top-level heading::Some second-level heading::My Heading`.
785725
parameters:
786726
- description: "Patch operation to perform"
787727
in: "header"
@@ -1259,6 +1199,8 @@ paths:
12591199
12601200
Allows you to modify the content relative to a heading, block reference, or frontmatter field in your document.
12611201
1202+
Note that this API was changed in Version 3.0 of this extension and the earlier PATCH API is now deprecated. Requests made using the previous version of this API will continue to work until Version 4.0 is released. See https://github.com/coddingtonbear/obsidian-local-rest-api/wiki/Changes-to-PATCH-requests-between-versions-2.0-and-3.0 for more details and migration instructions.
1203+
12621204
# Examples
12631205
12641206
All of the below examples assume you have a document that looks like
@@ -1382,38 +1324,6 @@ paths:
13821324
interpreting yoru `prepend` or `append` requests if you specify
13831325
your data as JSON (particularly when appending, for example,
13841326
list items).
1385-
1386-
# Upgrading from Version 2.0 (heading-based) to Version 3.0 (target-based) APIs
1387-
1388-
This API was changed in version 3.0 of Obsidian Local REST API to support making changes to your document relative to ["block references"](https://help.obsidian.md/Linking+notes+and+files/Internal+links#Link+to+a+block+in+a+note) and frontmatter fields in addition to headings within your document.
1389-
Version 2.0 of this API (now undocumented) is still accessible as
1390-
long as your incoming request specifies the `Heading` header and
1391-
*does not* specify a `Target-Type` header. You should upgrade, though,
1392-
to the current version of the API as support for the Version 2.0 API is
1393-
now deprecated and will stop working in Version 4.0.
1394-
1395-
You can migrate to the current version of the API by following the below guidelines. The words "heading" and "header" both occur quite a lot in the below paragraphs so it may aid in your understanding if you keep in mind that "head**ing**" here refers to a heading existing within your markdown document and "head**er**" refers to an HTTP Header that you may set to a value as part of using this API.
1396-
1397-
1. Rename your `Heading` header to `Target`.
1398-
2. Add a new `Target-Type` header having the value `heading`.
1399-
3. Set the `Operation` header such that its value is `append` if you had either not set the `Content-Insertion-Position` header or had set it to `end`. Set it to `prepend` if you had set `Content-Insertion-Position` to `beginning`.
1400-
4. If you had set `Content-Insertion-Ignore-Newline` to `true`, set the `Trim-Target-Whitespace` header value to `true` also.
1401-
1402-
Aside from the above, there is one important thing to keep in mind: while the obsolete version of this API allowed you to specify just the terminal heading (e.g. content under `### My Heading` could be addressed by setting the `Heading` header to `My Heading`), the current version of this API requires that you provide the full path to your target heading (i.e. instead of `My Heading`, you must find the parent second level heading and and its parent top level heading) delimited by `::`. If `::` appears in your heading, you can override that value by setting the `Target-Delimiter` header.
1403-
1404-
For example, if you had previously set `Heading` to `My Heading` for adding content to "MY CONTENT" in a document like:
1405-
1406-
```markdown
1407-
# Some top-level heading
1408-
1409-
## Some second-level heading
1410-
1411-
### My Heading
1412-
1413-
MY CONTENT
1414-
```
1415-
1416-
you should now set yoru `Target` heading to `Some top-level heading::Some second-level heading::My Heading`.
14171327
parameters:
14181328
- description: "Patch operation to perform"
14191329
in: "header"

docs/src/lib/patch.jsonnet

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@
149149
description: |||
150150
Allows you to modify the content relative to a heading, block reference, or frontmatter field in your document.
151151
152+
Note that this API was changed in Version 3.0 of this extension and the earlier PATCH API is now deprecated. Requests made using the previous version of this API will continue to work until Version 4.0 is released. See https://github.com/coddingtonbear/obsidian-local-rest-api/wiki/Changes-to-PATCH-requests-between-versions-2.0-and-3.0 for more details and migration instructions.
153+
152154
# Examples
153155
154156
All of the below examples assume you have a document that looks like
@@ -272,37 +274,5 @@
272274
interpreting yoru `prepend` or `append` requests if you specify
273275
your data as JSON (particularly when appending, for example,
274276
list items).
275-
276-
# Upgrading from Version 2.0 (heading-based) to Version 3.0 (target-based) APIs
277-
278-
This API was changed in version 3.0 of Obsidian Local REST API to support making changes to your document relative to ["block references"](https://help.obsidian.md/Linking+notes+and+files/Internal+links#Link+to+a+block+in+a+note) and frontmatter fields in addition to headings within your document.
279-
Version 2.0 of this API (now undocumented) is still accessible as
280-
long as your incoming request specifies the `Heading` header and
281-
*does not* specify a `Target-Type` header. You should upgrade, though,
282-
to the current version of the API as support for the Version 2.0 API is
283-
now deprecated and will stop working in Version 4.0.
284-
285-
You can migrate to the current version of the API by following the below guidelines. The words "heading" and "header" both occur quite a lot in the below paragraphs so it may aid in your understanding if you keep in mind that "head**ing**" here refers to a heading existing within your markdown document and "head**er**" refers to an HTTP Header that you may set to a value as part of using this API.
286-
287-
1. Rename your `Heading` header to `Target`.
288-
2. Add a new `Target-Type` header having the value `heading`.
289-
3. Set the `Operation` header such that its value is `append` if you had either not set the `Content-Insertion-Position` header or had set it to `end`. Set it to `prepend` if you had set `Content-Insertion-Position` to `beginning`.
290-
4. If you had set `Content-Insertion-Ignore-Newline` to `true`, set the `Trim-Target-Whitespace` header value to `true` also.
291-
292-
Aside from the above, there is one important thing to keep in mind: while the obsolete version of this API allowed you to specify just the terminal heading (e.g. content under `### My Heading` could be addressed by setting the `Heading` header to `My Heading`), the current version of this API requires that you provide the full path to your target heading (i.e. instead of `My Heading`, you must find the parent second level heading and and its parent top level heading) delimited by `::`. If `::` appears in your heading, you can override that value by setting the `Target-Delimiter` header.
293-
294-
For example, if you had previously set `Heading` to `My Heading` for adding content to "MY CONTENT" in a document like:
295-
296-
```markdown
297-
# Some top-level heading
298-
299-
## Some second-level heading
300-
301-
### My Heading
302-
303-
MY CONTENT
304-
```
305-
306-
you should now set yoru `Target` heading to `Some top-level heading::Some second-level heading::My Heading`.
307277
|||,
308278
}

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "obsidian-local-rest-api",
33
"name": "Local REST API",
4-
"version": "3.0.1",
4+
"version": "3.0.2",
55
"minAppVersion": "0.12.0",
66
"description": "Get, change or otherwise interact with your notes in Obsidian via a REST API.",
77
"author": "Adam Coddington",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-local-rest-api",
3-
"version": "3.0.0",
3+
"version": "3.0.2",
44
"description": "Get, change or otherwise interact with your notes in Obsidian via a REST API.",
55
"main": "main.js",
66
"types": "main.d.ts",

src/requestHandler.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,17 @@ export default class RequestHandler {
451451

452452
await this.app.vault.adapter.write(path, content);
453453

454-
res.status(200).send(content);
454+
console.warn(
455+
`2.x PATCH implementation is deprecated and will be removed in version 4.0`
456+
);
457+
res
458+
.header("Deprecation", 'true; sunset-version="4.0"')
459+
.header(
460+
"Link",
461+
'<https://github.com/coddingtonbear/obsidian-local-rest-api/wiki/Changes-to-PATCH-requests-between-versions-2.0-and-3.0>; rel="alternate"'
462+
)
463+
.status(200)
464+
.send(content);
455465
}
456466

457467
async _vaultPatchV3(
@@ -523,12 +533,8 @@ export default class RequestHandler {
523533
createTargetIfMissing,
524534
} as PatchInstruction;
525535

526-
console.info("Incoming content ", fileContents);
527-
528536
const patched = applyPatch(fileContents, instruction);
529537

530-
console.info("Patched file as ", patched);
531-
532538
await this.app.vault.adapter.write(path, patched);
533539

534540
res.status(200).send(patched);

versions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@
4848
"2.5.3": "0.12.0",
4949
"2.5.4": "0.12.0",
5050
"3.0.0": "0.12.0",
51-
"3.0.1": "0.12.0"
51+
"3.0.1": "0.12.0",
52+
"3.0.2": "0.12.0"
5253
}

0 commit comments

Comments
 (0)