notion_ruby_mapping 4.0.2 → 4.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -1
- data/README.md +4 -3
- data/lib/notion_ruby_mapping/blocks/list.rb +1 -1
- data/lib/notion_ruby_mapping/controllers/mermaid_data_source.rb +3 -3
- data/lib/notion_ruby_mapping/controllers/rich_text_array.rb +4 -0
- data/lib/notion_ruby_mapping/properties/button_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/checkbox_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/created_time_property.rb +1 -1
- data/lib/notion_ruby_mapping/properties/email_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/files_property.rb +10 -16
- data/lib/notion_ruby_mapping/properties/last_edited_by_property.rb +0 -1
- data/lib/notion_ruby_mapping/properties/last_edited_time_property.rb +1 -1
- data/lib/notion_ruby_mapping/properties/multi_property.rb +1 -1
- data/lib/notion_ruby_mapping/properties/multi_select_property.rb +11 -11
- data/lib/notion_ruby_mapping/properties/number_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/people_property.rb +24 -5
- data/lib/notion_ruby_mapping/properties/phone_number_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/property.rb +13 -34
- data/lib/notion_ruby_mapping/properties/relation_property.rb +7 -7
- data/lib/notion_ruby_mapping/properties/rich_text_property.rb +0 -22
- data/lib/notion_ruby_mapping/properties/select_property.rb +11 -11
- data/lib/notion_ruby_mapping/properties/status_property.rb +50 -2
- data/lib/notion_ruby_mapping/properties/text_property.rb +59 -1
- data/lib/notion_ruby_mapping/properties/title_property.rb +0 -38
- data/lib/notion_ruby_mapping/properties/unique_id_property.rb +39 -3
- data/lib/notion_ruby_mapping/properties/url_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/verification_property.rb +8 -12
- data/lib/notion_ruby_mapping/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 366fc4989968bff0fb71d9376b58d3e270fa3e7d91581d37ab75653ec06cb8e3
|
|
4
|
+
data.tar.gz: e36897b1704fafa277c1996459d148abac1fcf03d62d9e23a8ee67a7325e9a11
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 531c093bf3a67cf10dba9208c1321c6f3a8d35f808195167947f761563cc961e3bac59be090c70dc7bfdee1f453bba964d160f912ad035ebdc114d441541765d
|
|
7
|
+
data.tar.gz: 3e7f35ff1b8bbcfc51052f34cc873da0f4436175faced7ac12140c34d0dff4b91f83b555ea888483643d068485c43a23714b7186dd9b8b950d957759a7c347dc
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [4.1.0] - 2026-08-23
|
|
4
|
+
|
|
5
|
+
### Removed
|
|
6
|
+
|
|
7
|
+
- `Property#contents?`
|
|
8
|
+
- `Property#assert_database_property`
|
|
9
|
+
- `def_delegators :retrieve_page_property` and `extend Forwardable` in `Property`
|
|
10
|
+
(a workaround for the 2022-06-28 API version, made unnecessary by the 2022-08-31 update)
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- `Property.create_from_json` now raises a `StandardError` when the given JSON has no `type` key
|
|
15
|
+
- Unsupported property types now raise a unified message:
|
|
16
|
+
`Unsupported property type: <type> (<name>). Please update notion_ruby_mapping.`
|
|
17
|
+
- `Property#update_from_json` now assigns the value whenever the key exists,
|
|
18
|
+
so `false` and empty values are reflected correctly
|
|
19
|
+
- `List#initialize` normalizes `query` to `Query.new` when `nil` is given
|
|
20
|
+
- `assert_*` methods use positive conditions and a consistent
|
|
21
|
+
`Database or DataSource property` wording
|
|
22
|
+
|
|
3
23
|
## [0.1.0] - 2022-02-07
|
|
4
24
|
|
|
5
|
-
- Initial release
|
|
25
|
+
- Initial release
|
data/README.md
CHANGED
|
@@ -143,9 +143,10 @@ NotionRubyMapping.configuration { |c| c.notion_token = ENV["NOTION_API_TOKEN"] }
|
|
|
143
143
|
|
|
144
144
|
## 3. ChangeLog
|
|
145
145
|
|
|
146
|
-
-
|
|
147
|
-
-
|
|
148
|
-
-
|
|
146
|
+
- 2026/8/23 [v4.1.0] Refactor Property base class (remove def_delegators and contents?, raise for unsupported property type)
|
|
147
|
+
- 2026/7/14 [v4.0.2] Add clear method for DateProperty
|
|
148
|
+
- 2026/5/4 [v4.0.1] Add retrieve / update / delete a comment
|
|
149
|
+
- 2026/3/23 [v4.0.0] Add markdown support, headnig_4, toggle_heading_4, and position support for appending blocks
|
|
149
150
|
- 2026/1/25 [v3.0.6] add move page, list templates, and create child page to page
|
|
150
151
|
- 2025/12/15 [v3.0.5] add AudioBlock
|
|
151
152
|
- 2025/12/9 [v3.0.4] Fix the issue where page.parent could not be executed for pages with a data source as parent
|
|
@@ -96,7 +96,7 @@ module NotionRubyMapping
|
|
|
96
96
|
|
|
97
97
|
when "multi_select"
|
|
98
98
|
if property
|
|
99
|
-
(options -
|
|
99
|
+
(options - property.multi_select_options.map { |h| h["name"] }).each do |select_name|
|
|
100
100
|
property.add_multi_select_option name: select_name, color: "default"
|
|
101
101
|
end
|
|
102
102
|
else
|
|
@@ -145,7 +145,7 @@ module NotionRubyMapping
|
|
|
145
145
|
end
|
|
146
146
|
when "select"
|
|
147
147
|
if property
|
|
148
|
-
(options -
|
|
148
|
+
(options - property.select_options.map { |h| h["name"] }).each do |select_name|
|
|
149
149
|
property.add_select_option name: select_name, color: "default"
|
|
150
150
|
end
|
|
151
151
|
else
|
|
@@ -165,7 +165,7 @@ module NotionRubyMapping
|
|
|
165
165
|
property = ps.values_at(forward).first
|
|
166
166
|
if property
|
|
167
167
|
if reverse
|
|
168
|
-
if property.
|
|
168
|
+
if property.relation_data_source_id == db_is && property.synced_property_name == reverse
|
|
169
169
|
relation_ds.add_property "relation", reverse
|
|
170
170
|
relation_ds.finish_flag[reverse] = true
|
|
171
171
|
else
|
|
@@ -79,6 +79,10 @@ module NotionRubyMapping
|
|
|
79
79
|
map(&:text).join ""
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
+
def clear
|
|
83
|
+
self.rich_text_objects = []
|
|
84
|
+
end
|
|
85
|
+
|
|
82
86
|
# @param [RichTextArray, String, Array<String>, RichTextObject, Array<RichTextObject>] text_info
|
|
83
87
|
def rich_text_objects=(text_info)
|
|
84
88
|
@will_update = true
|
|
@@ -9,13 +9,13 @@ module NotionRubyMapping
|
|
|
9
9
|
|
|
10
10
|
## Common methods
|
|
11
11
|
|
|
12
|
-
# @return [
|
|
12
|
+
# @return [Hash, nil]
|
|
13
13
|
def button
|
|
14
14
|
@json
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
# @param [String, Symbol] name Property name
|
|
18
|
-
# @param [
|
|
18
|
+
# @param [Hash, nil] json Button property object
|
|
19
19
|
def initialize(name, will_update: false, base_type: "page", property_id: nil, property_cache: nil, json: nil)
|
|
20
20
|
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
|
21
21
|
property_cache: property_cache
|
|
@@ -10,7 +10,7 @@ module NotionRubyMapping
|
|
|
10
10
|
|
|
11
11
|
## Common methods
|
|
12
12
|
|
|
13
|
-
# @return [Boolean, Hash,
|
|
13
|
+
# @return [Boolean, Hash] true/false for page property, schema hash for database/data_source property
|
|
14
14
|
# @see https://www.notion.so/hkob/CheckboxProperty-ac1edbdb8e264af5ad1432b522b429fd#20da1bf0cbcc4d4eb22d9125386522c2
|
|
15
15
|
def checkbox
|
|
16
16
|
@json
|
|
@@ -18,7 +18,7 @@ module NotionRubyMapping
|
|
|
18
18
|
|
|
19
19
|
## Page property only methods
|
|
20
20
|
|
|
21
|
-
# @param [Boolean] flag
|
|
21
|
+
# @param [Boolean] flag Checkbox value. Use true or false.
|
|
22
22
|
# @return [TrueClass, FalseClass] settled value
|
|
23
23
|
# @see https://www.notion.so/hkob/CheckboxProperty-ac1edbdb8e264af5ad1432b522b429fd#f167c85c1d2d40dfb8b3b6ce582e0f15
|
|
24
24
|
def checkbox=(flag)
|
|
@@ -39,7 +39,7 @@ module NotionRubyMapping
|
|
|
39
39
|
@json = if database_or_data_source?
|
|
40
40
|
json || {}
|
|
41
41
|
else
|
|
42
|
-
json
|
|
42
|
+
json.nil? ? false : json
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
45
|
|
|
@@ -13,14 +13,14 @@ module NotionRubyMapping
|
|
|
13
13
|
|
|
14
14
|
## Common methods
|
|
15
15
|
|
|
16
|
-
# @return [String, Hash]
|
|
16
|
+
# @return [String, Hash, nil] email address for page properties, empty hash for database/data source properties
|
|
17
17
|
def email
|
|
18
18
|
@json
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
## Page property only methods
|
|
22
22
|
|
|
23
|
-
# @param [String] email
|
|
23
|
+
# @param [String, nil] email
|
|
24
24
|
def email=(email)
|
|
25
25
|
assert_page_property __method__
|
|
26
26
|
@will_update = true
|
|
@@ -35,7 +35,7 @@ module NotionRubyMapping
|
|
|
35
35
|
def initialize(name, will_update: false, base_type: "page", json: nil, property_id: nil, property_cache: nil)
|
|
36
36
|
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
|
37
37
|
property_cache: property_cache
|
|
38
|
-
@json =
|
|
38
|
+
@json = database_or_data_source? ? {} : json
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
# @return [Hash]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module NotionRubyMapping
|
|
4
|
-
#
|
|
4
|
+
# Files property
|
|
5
5
|
class FilesProperty < Property
|
|
6
6
|
include IsEmptyIsNotEmpty
|
|
7
7
|
TYPE = "files"
|
|
@@ -12,6 +12,14 @@ module NotionRubyMapping
|
|
|
12
12
|
|
|
13
13
|
## Page property only methods
|
|
14
14
|
|
|
15
|
+
# Removes all files from the property.
|
|
16
|
+
#
|
|
17
|
+
# This method replaces the files array with an empty array.
|
|
18
|
+
def clear
|
|
19
|
+
assert_page_property __method__
|
|
20
|
+
self.files = []
|
|
21
|
+
end
|
|
22
|
+
|
|
15
23
|
def files=(files = [])
|
|
16
24
|
assert_page_property __method__
|
|
17
25
|
@will_update = true
|
|
@@ -22,7 +30,7 @@ module NotionRubyMapping
|
|
|
22
30
|
def file_names=(file_names = [])
|
|
23
31
|
array_file_names = Array(file_names)
|
|
24
32
|
unless @files.length == array_file_names.length
|
|
25
|
-
raise
|
|
33
|
+
raise ArgumentError,
|
|
26
34
|
"files and file_names must be the same sizes."
|
|
27
35
|
end
|
|
28
36
|
|
|
@@ -75,19 +83,5 @@ module NotionRubyMapping
|
|
|
75
83
|
@will_update = false
|
|
76
84
|
self
|
|
77
85
|
end
|
|
78
|
-
|
|
79
|
-
protected
|
|
80
|
-
|
|
81
|
-
# @param [String] url
|
|
82
|
-
# @return [Hash]
|
|
83
|
-
def url_to_hash(url)
|
|
84
|
-
{
|
|
85
|
-
"name" => url,
|
|
86
|
-
"type" => "external",
|
|
87
|
-
"external" => {
|
|
88
|
-
"url" => url,
|
|
89
|
-
},
|
|
90
|
-
}
|
|
91
|
-
end
|
|
92
86
|
end
|
|
93
87
|
end
|
|
@@ -9,7 +9,7 @@ module NotionRubyMapping
|
|
|
9
9
|
|
|
10
10
|
## Common methods
|
|
11
11
|
|
|
12
|
-
# @return [
|
|
12
|
+
# @return [String, Hash]
|
|
13
13
|
# @see https://www.notion.so/hkob/LastEditedTimeProperty-5058fd594f6748a48fd4db52535f4c18#a7b568bf997c44d49cdbe4bfbf29824e
|
|
14
14
|
def last_edited_time
|
|
15
15
|
@json
|
|
@@ -9,12 +9,12 @@ module NotionRubyMapping
|
|
|
9
9
|
|
|
10
10
|
## Common methods
|
|
11
11
|
|
|
12
|
-
# @return [Array
|
|
12
|
+
# @return [Array<Hash>, Hash] raw multi_select array for page property, or multi_select schema object for database/data_source property
|
|
13
13
|
def multi_select
|
|
14
14
|
@json
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
# @return [Array]
|
|
17
|
+
# @return [Array<String>] selected option names for page property, or schema option names for database/data_source property
|
|
18
18
|
def multi_select_names
|
|
19
19
|
mshs = @base_type == "page" ? @json : @json["options"]
|
|
20
20
|
mshs.map { |h| h["name"] }
|
|
@@ -24,30 +24,30 @@ module NotionRubyMapping
|
|
|
24
24
|
|
|
25
25
|
# @param [String] name
|
|
26
26
|
# @param [String] color
|
|
27
|
-
# @return [Array]
|
|
27
|
+
# @return [Array<Hash>] updated multi_select options
|
|
28
28
|
# @see https://www.notion.so/hkob/MultiSelectProperty-b90bba1c55d540ba97131bb013d4ca74#bcac830b00e04cb6bf7dbbb110d95667
|
|
29
29
|
def add_multi_select_option(name:, color:)
|
|
30
30
|
edit_multi_select_options << {"name" => name, "color" => color}
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
# @return [Array]
|
|
33
|
+
# @return [Array<Hash>] editable multi_select options
|
|
34
34
|
def edit_multi_select_options
|
|
35
35
|
assert_database_or_data_source_property __method__
|
|
36
36
|
@will_update = true
|
|
37
37
|
@json["options"] ||= []
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
# @return [Array]
|
|
40
|
+
# @return [Array<Hash>] schema multi_select options
|
|
41
41
|
# @see https://www.notion.so/hkob/MultiSelectProperty-b90bba1c55d540ba97131bb013d4ca74#5ff6ec299cf64049bde2416f61b30fa9
|
|
42
42
|
def multi_select_options
|
|
43
|
-
|
|
43
|
+
assert_database_or_data_source_property __method__
|
|
44
44
|
@json["options"] || []
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
## Page property only methods
|
|
48
48
|
|
|
49
|
-
# @param [
|
|
50
|
-
# @return [Array
|
|
49
|
+
# @param [String, Array<String>, nil] multi_select selected option name or names
|
|
50
|
+
# @return [Array<Hash>] settled array
|
|
51
51
|
def multi_select=(multi_select)
|
|
52
52
|
assert_page_property __method__
|
|
53
53
|
@will_update = true
|
|
@@ -59,8 +59,8 @@ module NotionRubyMapping
|
|
|
59
59
|
## Common methods
|
|
60
60
|
|
|
61
61
|
# @param [String, Symbol] name
|
|
62
|
-
# @param [Hash] json
|
|
63
|
-
# @param [Array<String>,
|
|
62
|
+
# @param [Hash, nil] json
|
|
63
|
+
# @param [String, Array<String>, nil] multi_select selected option name or names (optional)
|
|
64
64
|
def initialize(name, will_update: false, base_type: "page", json: nil, multi_select: nil,
|
|
65
65
|
property_id: nil, property_cache: nil)
|
|
66
66
|
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
|
@@ -89,7 +89,7 @@ module NotionRubyMapping
|
|
|
89
89
|
|
|
90
90
|
## Page property only methods
|
|
91
91
|
|
|
92
|
-
# @return [Hash]
|
|
92
|
+
# @return [Hash] page property values payload
|
|
93
93
|
def property_values_json
|
|
94
94
|
assert_page_property __method__
|
|
95
95
|
{
|
|
@@ -38,8 +38,8 @@ module NotionRubyMapping
|
|
|
38
38
|
|
|
39
39
|
## Page property only methods
|
|
40
40
|
|
|
41
|
-
# @param [Numeric] num
|
|
42
|
-
# @return [Numeric] settled number
|
|
41
|
+
# @param [Numeric, nil] num Number value. nil clears the value.
|
|
42
|
+
# @return [Numeric, nil] settled number
|
|
43
43
|
# @see https://www.notion.so/hkob/NumberProperty-964ebc1948074d7ca8340187aa352d40#a3f28cc7029046878dfd694b5b33e8d8
|
|
44
44
|
def number=(num)
|
|
45
45
|
assert_page_property __method__
|
|
@@ -9,7 +9,15 @@ module NotionRubyMapping
|
|
|
9
9
|
|
|
10
10
|
## Common methods
|
|
11
11
|
|
|
12
|
-
#
|
|
12
|
+
# Returns the people assigned to this property.
|
|
13
|
+
#
|
|
14
|
+
# For a page property, this returns an array of UserObject instances.
|
|
15
|
+
# For a database or data source property, this returns the schema payload.
|
|
16
|
+
#
|
|
17
|
+
# Do not modify the returned array directly. Use `people=` or `add_person`
|
|
18
|
+
# to update the property.
|
|
19
|
+
#
|
|
20
|
+
# @return [Array<UserObject>, Hash]
|
|
13
21
|
# @see https://www.notion.so/hkob/PeopleProperty-144355d25f0e4feba9ae39fe28ca6ae7#7e3e56c2080d4834902cfa0223e807e5
|
|
14
22
|
def people
|
|
15
23
|
@json
|
|
@@ -17,8 +25,13 @@ module NotionRubyMapping
|
|
|
17
25
|
|
|
18
26
|
## Page property only methods
|
|
19
27
|
|
|
20
|
-
#
|
|
21
|
-
#
|
|
28
|
+
# Adds a person to this people property.
|
|
29
|
+
#
|
|
30
|
+
# This method marks the property as changed.
|
|
31
|
+
# This method does not remove duplicate users.
|
|
32
|
+
#
|
|
33
|
+
# @param [String, UserObject] user_id_or_uo user ID or user object to add
|
|
34
|
+
# @return [Array<UserObject>] updated people
|
|
22
35
|
# @see https://www.notion.so/hkob/PeopleProperty-144355d25f0e4feba9ae39fe28ca6ae7#26344b145a254cc58dd845780e0a26ea
|
|
23
36
|
def add_person(user_id_or_uo)
|
|
24
37
|
assert_page_property __method__
|
|
@@ -26,8 +39,14 @@ module NotionRubyMapping
|
|
|
26
39
|
@json << UserObject.user_object(user_id_or_uo)
|
|
27
40
|
end
|
|
28
41
|
|
|
29
|
-
#
|
|
30
|
-
#
|
|
42
|
+
# Replaces all people in this property.
|
|
43
|
+
#
|
|
44
|
+
# Passing nil or an empty array clears the people property.
|
|
45
|
+
# This method marks the property as changed.
|
|
46
|
+
#
|
|
47
|
+
# @param [String, UserObject, Array<String>, Array<UserObject>, nil] people
|
|
48
|
+
# user ID, user object, array of them, or nil
|
|
49
|
+
# @return [Array<UserObject>] replaced people
|
|
31
50
|
# @see https://www.notion.so/hkob/PeopleProperty-144355d25f0e4feba9ae39fe28ca6ae7#815acfef9a664e3e8915fb31b8fefc42
|
|
32
51
|
def people=(people)
|
|
33
52
|
assert_page_property __method__
|
|
@@ -13,7 +13,7 @@ module NotionRubyMapping
|
|
|
13
13
|
|
|
14
14
|
## Common methods
|
|
15
15
|
|
|
16
|
-
# @return [String, Hash, nil] phone number
|
|
16
|
+
# @return [String, Hash, nil] phone number for page properties, empty hash for database/data source properties
|
|
17
17
|
# @see https://www.notion.so/hkob/PhoneNumberProperty-5df14aaa938c4888aecd53ab6752d2e6#40bceda04fe04c64b932d6a1ed180eaa
|
|
18
18
|
def phone_number
|
|
19
19
|
@json
|
|
@@ -21,7 +21,7 @@ module NotionRubyMapping
|
|
|
21
21
|
|
|
22
22
|
## Page property only methods
|
|
23
23
|
|
|
24
|
-
# @param [String] phone_number
|
|
24
|
+
# @param [String, nil] phone_number
|
|
25
25
|
# @see https://www.notion.so/hkob/PhoneNumberProperty-5df14aaa938c4888aecd53ab6752d2e6#dc7e00e0558d40f79ca5cade1fccef29
|
|
26
26
|
def phone_number=(phone_number)
|
|
27
27
|
assert_page_property __method__
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "forwardable"
|
|
4
|
-
|
|
5
3
|
module NotionRubyMapping
|
|
6
4
|
# abstract class for property
|
|
7
5
|
class Property
|
|
8
|
-
extend Forwardable
|
|
9
|
-
|
|
10
6
|
### Public announced methods
|
|
11
7
|
|
|
12
8
|
## Common methods
|
|
@@ -14,18 +10,6 @@ module NotionRubyMapping
|
|
|
14
10
|
attr_reader :name, :will_update, :property_id
|
|
15
11
|
attr_accessor :property_cache
|
|
16
12
|
|
|
17
|
-
def_delegators :retrieve_page_property, :<<, :[], :add_person, :add_relation, :checkbox, :checkbox=, :created_by,
|
|
18
|
-
:created_time, :date, :each, :email, :email=, :end_date, :end_date=, :files, :files=, :filter_after,
|
|
19
|
-
:filter_before, :filter_contains, :filter_does_not_contain, :filter_does_not_equal,
|
|
20
|
-
:filter_ends_with, :filter_equals, :filter_greater_than, :filter_greater_than_or_equal_to,
|
|
21
|
-
:filter_is_empty, :filter_is_not_empty, :filter_less_than, :filter_less_than_or_equal_to,
|
|
22
|
-
:filter_next_month, :filter_next_week, :filter_next_year, :filter_on_or_after, :filter_on_or_before,
|
|
23
|
-
:filter_past_month, :filter_past_week, :filter_past_year, :filter_starts_with, :formula, :full_text,
|
|
24
|
-
:last_edited_by, :last_edited_time, :multi_select, :multi_select=, :multi_select_names, :number,
|
|
25
|
-
:number=, :people, :people=, :phone_number, :phone_number=, :property_values_json, :relation=,
|
|
26
|
-
:rollup, :start_date, :start_date=, :time_zone, :time_zone=, :select, :select=, :select_name, :url,
|
|
27
|
-
:url=, :start_date_obj, :end_date_obj
|
|
28
|
-
|
|
29
13
|
## Database property only methods
|
|
30
14
|
|
|
31
15
|
# @param [String] new_name
|
|
@@ -72,12 +56,13 @@ module NotionRubyMapping
|
|
|
72
56
|
|
|
73
57
|
type = input_json["type"]
|
|
74
58
|
if type.nil?
|
|
75
|
-
|
|
59
|
+
raise StandardError, "Property value is not returned: #{name}"
|
|
76
60
|
elsif type == "property_item"
|
|
77
61
|
tmp = new name, property_id: input_json["property_item"]["id"], base_type: base_type,
|
|
78
62
|
property_cache: property_cache, query: query
|
|
79
63
|
objects = List.new(json: input_json, type: "property", value: tmp, query: query).to_a
|
|
80
|
-
|
|
64
|
+
input_type = input_json["property_item"]["type"]
|
|
65
|
+
case input_type
|
|
81
66
|
when "people"
|
|
82
67
|
PeopleProperty.new name, people: objects, base_type: base_type,
|
|
83
68
|
property_cache: property_cache, query: query
|
|
@@ -94,7 +79,7 @@ module NotionRubyMapping
|
|
|
94
79
|
TitleProperty.new name, text_objects: objects, base_type: base_type,
|
|
95
80
|
property_cache: property_cache, query: query
|
|
96
81
|
else
|
|
97
|
-
raise StandardError, "
|
|
82
|
+
raise StandardError, "Unsupported property type: #{input_type} (#{name}). Please update notion_ruby_mapping."
|
|
98
83
|
end
|
|
99
84
|
else
|
|
100
85
|
klass = {
|
|
@@ -123,7 +108,10 @@ module NotionRubyMapping
|
|
|
123
108
|
url: UrlProperty,
|
|
124
109
|
verification: VerificationProperty,
|
|
125
110
|
}[type.to_sym]
|
|
126
|
-
|
|
111
|
+
unless klass
|
|
112
|
+
raise StandardError,
|
|
113
|
+
"Unsupported property type: #{type} (#{name}). Please update notion_ruby_mapping."
|
|
114
|
+
end
|
|
127
115
|
|
|
128
116
|
answer = klass.new name, property_id: input_json["id"], json: input_json[type], base_type: base_type,
|
|
129
117
|
property_cache: property_cache
|
|
@@ -152,11 +140,6 @@ module NotionRubyMapping
|
|
|
152
140
|
%w[database data_source].include? @base_type
|
|
153
141
|
end
|
|
154
142
|
|
|
155
|
-
# @return [TrueClass, FalseClass] true if it has Property contents
|
|
156
|
-
def contents?
|
|
157
|
-
!instance_of? Property
|
|
158
|
-
end
|
|
159
|
-
|
|
160
143
|
# @param [String] key query parameter
|
|
161
144
|
# @param [Object] value query value
|
|
162
145
|
# @return [NotionRubyMapping::Query] generated Query object
|
|
@@ -180,9 +163,9 @@ module NotionRubyMapping
|
|
|
180
163
|
# @param [Hash] json
|
|
181
164
|
def update_from_json(json)
|
|
182
165
|
@will_update = false
|
|
183
|
-
return unless
|
|
166
|
+
return unless json.key?(type)
|
|
184
167
|
|
|
185
|
-
@json = json[type]
|
|
168
|
+
@json = json[type]
|
|
186
169
|
end
|
|
187
170
|
|
|
188
171
|
# @return [Symbol] property type
|
|
@@ -192,14 +175,9 @@ module NotionRubyMapping
|
|
|
192
175
|
|
|
193
176
|
## Database property only methods
|
|
194
177
|
|
|
195
|
-
# @param [Symbol, nil] method
|
|
196
|
-
def assert_database_property(method)
|
|
197
|
-
raise StandardError, "#{method} can execute only Database property." unless database?
|
|
198
|
-
end
|
|
199
|
-
|
|
200
178
|
# @param [Symbol, nil] method
|
|
201
179
|
def assert_database_or_data_source_property(method)
|
|
202
|
-
raise StandardError, "#{method} can execute only Database property."
|
|
180
|
+
raise StandardError, "#{method} can execute only Database or DataSource property." unless database_or_data_source?
|
|
203
181
|
end
|
|
204
182
|
|
|
205
183
|
# @return [Hash]
|
|
@@ -209,6 +187,7 @@ module NotionRubyMapping
|
|
|
209
187
|
end
|
|
210
188
|
|
|
211
189
|
## DataSource property only methods
|
|
190
|
+
# @param [Symbol, nil] method
|
|
212
191
|
def assert_data_source_property(method)
|
|
213
192
|
raise StandardError, "#{method} can execute only DataSource property." unless data_source?
|
|
214
193
|
end
|
|
@@ -229,7 +208,7 @@ module NotionRubyMapping
|
|
|
229
208
|
|
|
230
209
|
# @param [Symbol, nil] method
|
|
231
210
|
def assert_page_property(method)
|
|
232
|
-
raise StandardError, "#{method} can execute only Page property."
|
|
211
|
+
raise StandardError, "#{method} can execute only Page property." unless page?
|
|
233
212
|
end
|
|
234
213
|
|
|
235
214
|
# @return [NotionRubyMapping::Property, Array<UserObject>, nil]
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module NotionRubyMapping
|
|
4
|
-
#
|
|
4
|
+
# Relation property
|
|
5
5
|
class RelationProperty < MultiProperty
|
|
6
6
|
TYPE = "relation"
|
|
7
|
+
RELATION_PROPERTY_TYPES = %w[dual_property single_property].freeze
|
|
7
8
|
|
|
8
9
|
### Public announced methods
|
|
9
10
|
|
|
10
11
|
## Common methods
|
|
11
12
|
|
|
12
|
-
# @return [Hash
|
|
13
|
+
# @return [Array<Hash>, Hash, nil] relation value or relation schema
|
|
13
14
|
# @see https://www.notion.so/hkob/RelationProperty-f608ab41a1f0476b98456620346fba03#6c14207b2d1340d2bbc08d17eee2cb22
|
|
14
15
|
def relation
|
|
15
16
|
@json
|
|
@@ -35,6 +36,7 @@ module NotionRubyMapping
|
|
|
35
36
|
def relation=(page_ids_or_jsons)
|
|
36
37
|
assert_page_property __method__
|
|
37
38
|
@will_update = true
|
|
39
|
+
page_ids_or_jsons = [] if page_ids_or_jsons.nil?
|
|
38
40
|
page_ids_or_jsons = [page_ids_or_jsons] unless page_ids_or_jsons.is_a? Array
|
|
39
41
|
|
|
40
42
|
@json = page_ids_or_jsons.map do |page_id_or_json|
|
|
@@ -47,7 +49,7 @@ module NotionRubyMapping
|
|
|
47
49
|
# @return [String] relation data_source_id
|
|
48
50
|
# @see https://www.notion.so/hkob/RelationProperty-f608ab41a1f0476b98456620346fba03#eb40f1a2ad5c4e368d343870a7e529f9
|
|
49
51
|
def relation_data_source_id
|
|
50
|
-
|
|
52
|
+
assert_database_or_data_source_property __method__
|
|
51
53
|
@json["data_source_id"]
|
|
52
54
|
end
|
|
53
55
|
|
|
@@ -56,6 +58,8 @@ module NotionRubyMapping
|
|
|
56
58
|
# @see https://www.notion.so/hkob/RelationProperty-f608ab41a1f0476b98456620346fba03#7f5029fb7f6e4c009f22888b233e6f64
|
|
57
59
|
def replace_relation_data_source(data_source_id: nil, type: "dual_property")
|
|
58
60
|
assert_database_or_data_source_property __method__
|
|
61
|
+
raise ArgumentError, "type must be dual_property or single_property" unless RELATION_PROPERTY_TYPES.include? type
|
|
62
|
+
|
|
59
63
|
@will_update = true
|
|
60
64
|
@json["data_source_id"] = data_source_id if data_source_id
|
|
61
65
|
@json["type"] = type
|
|
@@ -97,10 +101,6 @@ module NotionRubyMapping
|
|
|
97
101
|
ans
|
|
98
102
|
end
|
|
99
103
|
|
|
100
|
-
def data_source_id
|
|
101
|
-
@json["data_source_id"]
|
|
102
|
-
end
|
|
103
|
-
|
|
104
104
|
# @return [TrueClass, FalseClass] true if dual_property
|
|
105
105
|
def dual_property?
|
|
106
106
|
assert_database_or_data_source_property __method__
|
|
@@ -9,28 +9,6 @@ module NotionRubyMapping
|
|
|
9
9
|
|
|
10
10
|
## Common methods
|
|
11
11
|
|
|
12
|
-
# @param [Hash] json
|
|
13
|
-
def update_from_json(json)
|
|
14
|
-
@will_update = false
|
|
15
|
-
if database_or_data_source?
|
|
16
|
-
@json = json["rich_text"] || {}
|
|
17
|
-
else
|
|
18
|
-
@text_objects = RichTextArray.new "rich_text", json: json["rich_text"]
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
12
|
## Page property only methods
|
|
23
|
-
|
|
24
|
-
# @return [Hash] created json
|
|
25
|
-
def property_values_json
|
|
26
|
-
assert_page_property __method__
|
|
27
|
-
text_json = @text_objects.map(&:property_values_json)
|
|
28
|
-
{
|
|
29
|
-
@name => {
|
|
30
|
-
"type" => "rich_text",
|
|
31
|
-
"rich_text" => text_json.empty? ? (@json || []) : text_json,
|
|
32
|
-
},
|
|
33
|
-
}
|
|
34
|
-
end
|
|
35
13
|
end
|
|
36
14
|
end
|
|
@@ -11,7 +11,7 @@ module NotionRubyMapping
|
|
|
11
11
|
|
|
12
12
|
## Common methods
|
|
13
13
|
|
|
14
|
-
# @return [Hash]
|
|
14
|
+
# @return [Hash] raw select object for page property, or select schema object for database/data_source property
|
|
15
15
|
# @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#7ad3734ac42c43068f1e04633bab400b
|
|
16
16
|
def select
|
|
17
17
|
@json
|
|
@@ -19,7 +19,7 @@ module NotionRubyMapping
|
|
|
19
19
|
|
|
20
20
|
## Page property only methods
|
|
21
21
|
|
|
22
|
-
# @return [String]
|
|
22
|
+
# @return [String, nil]
|
|
23
23
|
# @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#27a05e52715a4acd9156b5f146653e51
|
|
24
24
|
def select_name
|
|
25
25
|
assert_page_property __method__
|
|
@@ -30,27 +30,27 @@ module NotionRubyMapping
|
|
|
30
30
|
|
|
31
31
|
# @param [String] name
|
|
32
32
|
# @param [String] color
|
|
33
|
-
# @return [Array]
|
|
33
|
+
# @return [Array<Hash>] updated select options
|
|
34
34
|
# @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#3e1c7dbda7fb455f94ee93d9653b7880
|
|
35
35
|
def add_select_option(name:, color:)
|
|
36
36
|
edit_select_options << {"name" => name, "color" => color}
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
# @return [Array]
|
|
39
|
+
# @return [Array<Hash>] editable select options
|
|
40
40
|
def edit_select_options
|
|
41
41
|
assert_database_or_data_source_property __method__
|
|
42
42
|
@will_update = true
|
|
43
43
|
@json["options"] ||= []
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
# @return [Array]
|
|
46
|
+
# @return [Array<Hash>]
|
|
47
47
|
# @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#790a297f2c1b4ba5a4d86074d4c70a89
|
|
48
48
|
def select_options
|
|
49
49
|
assert_database_or_data_source_property __method__
|
|
50
50
|
@json["options"] || []
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
# @return [String]
|
|
53
|
+
# @return [Array<String>]
|
|
54
54
|
# @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#72da1632793c4a5296f3bc89de2df413
|
|
55
55
|
def select_names
|
|
56
56
|
assert_database_or_data_source_property __method__
|
|
@@ -59,12 +59,12 @@ module NotionRubyMapping
|
|
|
59
59
|
|
|
60
60
|
## Page property only methods
|
|
61
61
|
|
|
62
|
-
# @param [String]
|
|
62
|
+
# @param [String, nil] name
|
|
63
63
|
# @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#3bd195bf5c0a498ebf850409f7deb67a
|
|
64
|
-
def select=(
|
|
64
|
+
def select=(name)
|
|
65
65
|
assert_page_property __method__
|
|
66
66
|
@will_update = true
|
|
67
|
-
@json = {"name" =>
|
|
67
|
+
@json = {"name" => name}
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
### Not public announced methods
|
|
@@ -72,8 +72,8 @@ module NotionRubyMapping
|
|
|
72
72
|
## Common methods
|
|
73
73
|
|
|
74
74
|
# @param [String, Symbol] name Property name
|
|
75
|
-
# @param [Hash] json
|
|
76
|
-
# @param [String] select
|
|
75
|
+
# @param [Hash, nil] json
|
|
76
|
+
# @param [String, nil] select select option name (optional)
|
|
77
77
|
def initialize(name, will_update: false, base_type: "page", json: nil, select: nil, property_id: nil,
|
|
78
78
|
property_cache: nil)
|
|
79
79
|
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
|
@@ -25,8 +25,6 @@ module NotionRubyMapping
|
|
|
25
25
|
@json["name"]
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
## Page property only methods
|
|
29
|
-
|
|
30
28
|
# @param [String] status
|
|
31
29
|
# @see https://www.notion.so/hkob/StatusProperty-c8b2c83019bc42edbc1527386c7ef453#b3fba1b6322140f28308de3ba70a8b7b
|
|
32
30
|
def status=(status)
|
|
@@ -35,6 +33,35 @@ module NotionRubyMapping
|
|
|
35
33
|
@json = {"name" => status}
|
|
36
34
|
end
|
|
37
35
|
|
|
36
|
+
## Database or DataSource property only methods
|
|
37
|
+
# @param [String] name
|
|
38
|
+
# @param [String] color
|
|
39
|
+
# @return [Array<Hash>] updated status options
|
|
40
|
+
def add_status_option(name:, color:, group: nil)
|
|
41
|
+
hash = {"name" => name, "color" => color}
|
|
42
|
+
hash["group"] = group if group
|
|
43
|
+
edit_status_options << hash
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# @return [Array<Hash>] editable status options
|
|
47
|
+
def edit_status_options
|
|
48
|
+
assert_database_or_data_source_property __method__
|
|
49
|
+
@will_update = true
|
|
50
|
+
@json["edit_options"] ||= []
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# @return [Array<Hash>] status options
|
|
54
|
+
def status_options
|
|
55
|
+
assert_database_or_data_source_property __method__
|
|
56
|
+
@json["options"] || []
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# @return [Array<String>] status option names
|
|
60
|
+
def status_names
|
|
61
|
+
assert_database_or_data_source_property __method__
|
|
62
|
+
status_options.map { |s| s["name"] }
|
|
63
|
+
end
|
|
64
|
+
|
|
38
65
|
### Not public announced methods
|
|
39
66
|
|
|
40
67
|
## Common methods
|
|
@@ -54,5 +81,26 @@ module NotionRubyMapping
|
|
|
54
81
|
assert_page_property __method__
|
|
55
82
|
{@name => {"status" => @json, "type" => "status"}}
|
|
56
83
|
end
|
|
84
|
+
|
|
85
|
+
## Database property only methods
|
|
86
|
+
|
|
87
|
+
# @return [Hash]
|
|
88
|
+
def update_property_schema_json
|
|
89
|
+
assert_database_or_data_source_property __method__
|
|
90
|
+
ans = super
|
|
91
|
+
return ans if ans != {} || !@will_update
|
|
92
|
+
|
|
93
|
+
ans[@name] ||= {}
|
|
94
|
+
ans[@name]["status"] ||= {}
|
|
95
|
+
ans[@name]["status"]["options"] = @json["edit_options"]
|
|
96
|
+
ans
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
## Database property only methods
|
|
100
|
+
|
|
101
|
+
# @return [Hash]
|
|
102
|
+
def property_schema_json_sub
|
|
103
|
+
@json["edit_options"] ? {"options" => @json["edit_options"]} : {}
|
|
104
|
+
end
|
|
57
105
|
end
|
|
58
106
|
end
|
|
@@ -5,6 +5,7 @@ require "forwardable"
|
|
|
5
5
|
module NotionRubyMapping
|
|
6
6
|
# Text property
|
|
7
7
|
class TextProperty < Property
|
|
8
|
+
TYPE = "text"
|
|
8
9
|
extend Forwardable
|
|
9
10
|
include Enumerable
|
|
10
11
|
include EqualsDoesNotEqual
|
|
@@ -36,10 +37,67 @@ module NotionRubyMapping
|
|
|
36
37
|
@text_objects = if database_or_data_source?
|
|
37
38
|
json || {}
|
|
38
39
|
else
|
|
39
|
-
RichTextArray.new
|
|
40
|
+
RichTextArray.new self.class::TYPE, json: json, text_objects: text_objects
|
|
40
41
|
end
|
|
41
42
|
end
|
|
42
43
|
|
|
44
|
+
def self.rich_text_array_from_json(json)
|
|
45
|
+
if json["object"] == "list"
|
|
46
|
+
rich_text_objects = List.new(json: json, type: "property", value: self).select { true }
|
|
47
|
+
RichTextArray.rich_text_array self::TYPE, rich_text_objects
|
|
48
|
+
else
|
|
49
|
+
RichTextArray.new self::TYPE, json: json[self::TYPE]
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# @return [Hash] created json
|
|
54
|
+
def property_values_json
|
|
55
|
+
assert_page_property __method__
|
|
56
|
+
text_json = @text_objects.map(&:property_values_json)
|
|
57
|
+
{
|
|
58
|
+
@name => {
|
|
59
|
+
"type" => self.class::TYPE,
|
|
60
|
+
self.class::TYPE => text_json.empty? ? (@json || []) : text_json,
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Replaces all rich text objects with a single plain text object.
|
|
66
|
+
#
|
|
67
|
+
# This method does not preserve annotations, links, mentions, or equations.
|
|
68
|
+
#
|
|
69
|
+
# @param [String] text
|
|
70
|
+
# @raise [ArgumentError] if text is nil
|
|
71
|
+
def plain_text=(text)
|
|
72
|
+
assert_page_property __method__
|
|
73
|
+
raise ArgumentError if text.nil?
|
|
74
|
+
|
|
75
|
+
@text_objects = RichTextArray.new(
|
|
76
|
+
self.class::TYPE,
|
|
77
|
+
text_objects: text,
|
|
78
|
+
)
|
|
79
|
+
@will_update = true
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# @param [Hash] json
|
|
83
|
+
def update_from_json(json)
|
|
84
|
+
@will_update = false
|
|
85
|
+
if database_or_data_source?
|
|
86
|
+
@json = json[self.class::TYPE] || {}
|
|
87
|
+
else
|
|
88
|
+
@text_objects = self.class.rich_text_array_from_json json
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Removes all rich text objects.
|
|
93
|
+
#
|
|
94
|
+
# This method makes the property value an empty rich text array.
|
|
95
|
+
def clear
|
|
96
|
+
assert_page_property __method__
|
|
97
|
+
@text_objects.clear
|
|
98
|
+
@will_update = true
|
|
99
|
+
end
|
|
100
|
+
|
|
43
101
|
# @return [FalseClass]
|
|
44
102
|
def clear_will_update
|
|
45
103
|
super
|
|
@@ -9,44 +9,6 @@ module NotionRubyMapping
|
|
|
9
9
|
|
|
10
10
|
## Common methods
|
|
11
11
|
|
|
12
|
-
def self.rich_text_array_from_json(json)
|
|
13
|
-
if json["object"] == "list"
|
|
14
|
-
rich_text_objects = List.new(json: json, type: "property", value: self).select { true }
|
|
15
|
-
RichTextArray.rich_text_array "title", rich_text_objects
|
|
16
|
-
else
|
|
17
|
-
RichTextArray.new "title", json: json["title"]
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# @param [Hash] json
|
|
22
|
-
def update_from_json(json)
|
|
23
|
-
@will_update = false
|
|
24
|
-
if database_or_data_source?
|
|
25
|
-
@json = json || {}
|
|
26
|
-
else
|
|
27
|
-
@text_objects = TitleProperty.rich_text_array_from_json json
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
12
|
## Page property only methods
|
|
32
|
-
|
|
33
|
-
# @return [FalseClass]
|
|
34
|
-
def clear_will_update
|
|
35
|
-
super
|
|
36
|
-
@text_objects.clear_will_update
|
|
37
|
-
false
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# @return [Hash] created json
|
|
41
|
-
def property_values_json
|
|
42
|
-
assert_page_property __method__
|
|
43
|
-
text_json = map(&:property_values_json)
|
|
44
|
-
{
|
|
45
|
-
@name => {
|
|
46
|
-
"type" => "title",
|
|
47
|
-
"title" => text_json.empty? ? @json : text_json,
|
|
48
|
-
},
|
|
49
|
-
}
|
|
50
|
-
end
|
|
51
13
|
end
|
|
52
14
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module NotionRubyMapping
|
|
4
|
-
#
|
|
4
|
+
# Unique ID property
|
|
5
5
|
class UniqueIdProperty < Property
|
|
6
6
|
include EqualsDoesNotEqual
|
|
7
7
|
include GreaterThanLessThan
|
|
@@ -17,8 +17,26 @@ module NotionRubyMapping
|
|
|
17
17
|
@json
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
# @return [String, nil]
|
|
21
|
+
def prefix
|
|
22
|
+
@json && @json["prefix"]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @return [Integer, nil]
|
|
26
|
+
def number
|
|
27
|
+
@json && @json["number"]
|
|
28
|
+
end
|
|
29
|
+
|
|
20
30
|
## Database property only methods
|
|
21
31
|
|
|
32
|
+
# @param [String, nil] prefix
|
|
33
|
+
# @return [String, nil]
|
|
34
|
+
def prefix=(prefix)
|
|
35
|
+
assert_database_or_data_source_property __method__
|
|
36
|
+
@will_update = true
|
|
37
|
+
@json["prefix"] = prefix
|
|
38
|
+
end
|
|
39
|
+
|
|
22
40
|
## Page property only methods
|
|
23
41
|
|
|
24
42
|
### Not public announced methods
|
|
@@ -26,7 +44,7 @@ module NotionRubyMapping
|
|
|
26
44
|
## Common methods
|
|
27
45
|
|
|
28
46
|
# @param [String] name Property name
|
|
29
|
-
# @param [
|
|
47
|
+
# @param [Hash, nil] json unique_id Hash
|
|
30
48
|
def initialize(name, will_update: false, base_type: "page", json: nil, property_id: nil, property_cache: nil)
|
|
31
49
|
super name, will_update: will_update, base_type: base_type, property_id: property_id, property_cache: property_cache
|
|
32
50
|
@json = json
|
|
@@ -34,7 +52,7 @@ module NotionRubyMapping
|
|
|
34
52
|
end
|
|
35
53
|
|
|
36
54
|
# @param [Hash] json
|
|
37
|
-
# @return [NotionRubyMapping::
|
|
55
|
+
# @return [NotionRubyMapping::UniqueIdProperty]
|
|
38
56
|
def update_from_json(json)
|
|
39
57
|
@will_update = false
|
|
40
58
|
@json = json["unique_id"]
|
|
@@ -43,6 +61,17 @@ module NotionRubyMapping
|
|
|
43
61
|
|
|
44
62
|
## Database property only methods
|
|
45
63
|
|
|
64
|
+
# @return [Hash]
|
|
65
|
+
def update_property_schema_json
|
|
66
|
+
assert_database_or_data_source_property __method__
|
|
67
|
+
ans = super
|
|
68
|
+
return ans if ans != {} || !@will_update
|
|
69
|
+
|
|
70
|
+
ans[@name] ||= {}
|
|
71
|
+
ans[@name]["unique_id"] = @json
|
|
72
|
+
ans
|
|
73
|
+
end
|
|
74
|
+
|
|
46
75
|
## Page property only methods
|
|
47
76
|
|
|
48
77
|
# @return [Hash]
|
|
@@ -51,6 +80,13 @@ module NotionRubyMapping
|
|
|
51
80
|
{@name => {"unique_id" => @json, "type" => "unique_id"}}
|
|
52
81
|
end
|
|
53
82
|
|
|
83
|
+
protected
|
|
84
|
+
|
|
54
85
|
## Database property only methods
|
|
86
|
+
|
|
87
|
+
# @return [Hash]
|
|
88
|
+
def property_schema_json_sub
|
|
89
|
+
{"prefix" => prefix}
|
|
90
|
+
end
|
|
55
91
|
end
|
|
56
92
|
end
|
|
@@ -13,7 +13,7 @@ module NotionRubyMapping
|
|
|
13
13
|
|
|
14
14
|
## Common methods
|
|
15
15
|
|
|
16
|
-
# @return [String, Hash, nil]
|
|
16
|
+
# @return [String, Hash, nil] URL for page properties, empty hash for database/data source properties
|
|
17
17
|
# @see https://www.notion.so/hkob/UrlProperty-8a0094fdf6494151983cb4694f6626cc#8342eef7df3c43eaad10c48d4757b4ae
|
|
18
18
|
def url
|
|
19
19
|
@json
|
|
@@ -21,7 +21,7 @@ module NotionRubyMapping
|
|
|
21
21
|
|
|
22
22
|
## Page property only methods
|
|
23
23
|
|
|
24
|
-
# @param [String] url
|
|
24
|
+
# @param [String, nil] url
|
|
25
25
|
# @see https://www.notion.so/hkob/UrlProperty-8a0094fdf6494151983cb4694f6626cc#cfa5463a121b4002b250b38d7d0a0d34
|
|
26
26
|
def url=(url)
|
|
27
27
|
assert_page_property __method__
|
|
@@ -37,7 +37,7 @@ module NotionRubyMapping
|
|
|
37
37
|
def initialize(name, will_update: false, base_type: "page", json: nil, property_id: nil, property_cache: nil)
|
|
38
38
|
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
|
39
39
|
property_cache: property_cache
|
|
40
|
-
@json =
|
|
40
|
+
@json = database_or_data_source? ? {} : json
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
## Page property only methods
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module NotionRubyMapping
|
|
4
|
-
#
|
|
4
|
+
# Verification property
|
|
5
5
|
class VerificationProperty < Property
|
|
6
6
|
TYPE = "verification"
|
|
7
7
|
|
|
@@ -9,21 +9,16 @@ module NotionRubyMapping
|
|
|
9
9
|
|
|
10
10
|
## Common methods
|
|
11
11
|
|
|
12
|
-
# @see https://www.notion.so/hkob/StatusProperty-c8b2c83019bc42edbc1527386c7ef453#bdb34c0aeaa74729887da087d0bd8022
|
|
13
12
|
def verification
|
|
14
13
|
@json
|
|
15
14
|
end
|
|
16
15
|
|
|
17
|
-
## Page property only methods
|
|
18
|
-
|
|
19
|
-
## Page property only methods
|
|
20
|
-
|
|
21
16
|
### Not public announced methods
|
|
22
17
|
|
|
23
18
|
## Common methods
|
|
24
19
|
|
|
25
20
|
# @param [String, Symbol] name Property name
|
|
26
|
-
# @param [
|
|
21
|
+
# @param [Hash] json
|
|
27
22
|
def initialize(name, will_update: false, base_type: "page", property_id: nil, property_cache: nil, json: {})
|
|
28
23
|
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
|
29
24
|
property_cache: property_cache
|
|
@@ -32,11 +27,12 @@ module NotionRubyMapping
|
|
|
32
27
|
|
|
33
28
|
## DataSource only methods
|
|
34
29
|
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
# @param [String]
|
|
38
|
-
# @
|
|
39
|
-
# @
|
|
30
|
+
# Creates a filter query for the verification status.
|
|
31
|
+
#
|
|
32
|
+
# @param [String] value Verification status. Expected values are "verified", "expired", and "none".
|
|
33
|
+
# @param [String, nil] condition Rollup condition name.
|
|
34
|
+
# @param [String, nil] another_type Rollup target type.
|
|
35
|
+
# @return [NotionRubyMapping::Query] Generated Query object.
|
|
40
36
|
def filter_status(value, condition: nil, another_type: nil)
|
|
41
37
|
make_filter_query "status", value, condition: condition, another_type: another_type
|
|
42
38
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: notion_ruby_mapping
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.0
|
|
4
|
+
version: 4.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hiroyuki KOBAYASHI
|
|
@@ -349,7 +349,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
349
349
|
- !ruby/object:Gem::Version
|
|
350
350
|
version: '0'
|
|
351
351
|
requirements: []
|
|
352
|
-
rubygems_version: 4.0.
|
|
352
|
+
rubygems_version: 4.0.16
|
|
353
353
|
specification_version: 4
|
|
354
354
|
summary: Notion Ruby mapping tool
|
|
355
355
|
test_files: []
|